-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement Write trait for MaybeUninit<u8> #94665
Conversation
r? @m-ou-se (rust-highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
c7ea1f2
to
f18a951
Compare
Fixed the benchmark and added one for MaybeUninit:
|
I'm not sure if this is the right kind of API we want to provide for this. The guarantee that the written part is properly initialized and usable as |
Would it make sense to implement Write for |
@SUPERCILEX |
I'm waiting on a reply to my above comment. |
@m-ou-se ☝️ ? |
☔ The latest upstream changes (presumably #97910) made this pull request unmergeable. Please resolve the merge conflicts. |
@m-ou-se - can you comment on this? |
This has been implemented in #97015. You can now do this: let mut buf = [MaybeUninit::<u8>::uninit(); 20];
let mut buf: BorrowedBuf = buf.as_mut_slice().into();
write!(buf.unfilled(), "{}", 42).unwrap();
let buf: &[u8] = buf.filled(); |
This PR makes it possible to write something like the following: