bytecodealliance / rustix

Safe Rust bindings to POSIX-ish APIs
Other
1.46k stars 152 forks source link

Add uninit buffer ancillary APIs #1108

Open SUPERCILEX opened 1 month ago

SUPERCILEX commented 1 month ago

Pretty sure I managed to maintain backcompat via a conversion trait.

Closes #1103

SUPERCILEX commented 1 month ago

Nevermind, I don't think backcompat is possible without implementing a trait for both DerefMut<Target=[u8]> and DerefMut<Target=[MaybeUninit<u8>]> which I don't think you can do. Targeting the staging branch instead.

SUPERCILEX commented 1 month ago

Staging needs a rebase and also https://github.com/bytecodealliance/rustix/issues/1107

SUPERCILEX commented 1 month ago

Annnnnd I decided to make it backwards compatible again. The public API should be identical except there's now a From impl for MaybeUninit. 1.0 should break the ::new impl to take uninits instead.

SUPERCILEX commented 1 month ago

Not sure why the tests are so borked.

SUPERCILEX commented 1 month ago

Ok so the idea with this one is that the ::new methods would be swapped to use MaybeUninits for 1.0 and any way to construct a buffer with [u8] would be removed. I'm not really happy with the deprecation story as it feels like we'll just be springing this change on people, but I also don't see a way to allow seamless migration while preserving the name new.