-
Notifications
You must be signed in to change notification settings - Fork 278
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 BufMut for &mut [MaybeUninit<u8>]
#597
Conversation
72ef20d
to
8ca7c73
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a few more comments on the tests, but otherwise it looks good to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Ha, sorry, was actually in the middle of redoing tests. Now |
This will allow using BufMut without having to initialise memory first. In particular, this will allow simple integration with tokio: #![feature(maybe_uninit_slice)] use tokio::io::AsyncReadExt; let mut tokio_file = /* ... */; let mut buf = [MaybeUninit::uninit(); 4096]; let len = tokio_file.read_buf(&mut &mut buf[..]); // SAFETY: read initialised first len bytes of the buffer. let buf = unsafe { MaybeUninit::slice_assume_init_mut(&buf[..len]) };
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you.
This will allow using BufMut without having to initialise memory
first. In particular, this will allow simple integration with tokio: