rustix icon indicating copy to clipboard operation
rustix copied to clipboard

Add uninit buffer ancillary APIs

Open SUPERCILEX opened this issue 1 year ago • 5 comments

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

Closes #1103

SUPERCILEX avatar Aug 15 '24 01:08 SUPERCILEX

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 avatar Aug 15 '24 02:08 SUPERCILEX

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

SUPERCILEX avatar Aug 15 '24 02:08 SUPERCILEX

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 avatar Aug 15 '24 03:08 SUPERCILEX

Not sure why the tests are so borked.

SUPERCILEX avatar Aug 15 '24 03:08 SUPERCILEX

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.

SUPERCILEX avatar Aug 15 '24 21:08 SUPERCILEX

I've now rebased this and fixed the merge conflicts.

sunfishcode avatar Feb 26 '25 00:02 sunfishcode

Can we remove the non MaybeUninit versions? I personally don't think you should be using u8s for these buffers since we take care of giving you a nice well typed iterator.

SUPERCILEX avatar Feb 26 '25 01:02 SUPERCILEX

Yep, I was just reading your comment above about that too.

sunfishcode avatar Feb 26 '25 01:02 sunfishcode

Brilliant, this looks great!

SUPERCILEX avatar Feb 26 '25 01:02 SUPERCILEX

Thanks!

sunfishcode avatar Feb 26 '25 05:02 sunfishcode