Re: [PATCH 01/15] doc: add a policy for using Rust
- From
Ezekiel Newren <ezekielnewren@gmail.com>
- Date
- Aug 29, 2025, 20:11 UTC
- Message-ID
- <CAH=ZcbBJV0oT1Ht6qVKmq7xG8ki9Enutq+VNes4n9+2r+0nrvA@mail.gmail.com>
- In-Reply-To
- <aLIG5bLOisbxfn1y@fruit.crustytoothpaste.net>
On Fri, Aug 29, 2025 at 2:00 PM brian m. carlson <sandals@crustytoothpaste.net> wrote:
Show 16 quoted lines
> > +Tools like bindgen and cbindgen create C-styled unsafe Rust code rather than > > +idiomatic Rust; where possible, we prefer to switch to idiomatic Rust. Any > > +standard C library functions that are needed can be manually wrapped on the > > +Rust side. > > I agree that we want to use idiomatic Rust whenever possible. However, > I don't want to define structures and function definitions in both > languages and rely on people keeping them in sync, since that's a great > way to create brittle, broken code. Very notably, I have seen these > kinds of misalignments break only on big-endian architectures, which > most of us do not use, so we can really end up causing problems that are > very subtle this way. > > I would prefer we wrote these functions with cbindgen to avoid this. If > we define structures only in Rust and never ever use C structures, then > we can avoid bindgen.
Could you create a patch with your preferred wording about bindgen and cbindgen for me? I'd prefer to introduce bindgen/cbindgen in a different patch series because this one is already doing a lot just to make Rust exist in Git.