Implement Write trait for MaybeUninit<u8>#94665
Implement Write trait for MaybeUninit<u8>#94665SUPERCILEX wants to merge 1 commit intorust-lang:masterfrom
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: