-
Notifications
You must be signed in to change notification settings - Fork 287
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
Safe method for creating UninitSlice #552
Comments
Adding this seems fine to me. |
mina86
added a commit
to mina86/bytes
that referenced
this issue
Feb 9, 2023
Introduce UninitSlice::from_slice_mut and UninitSlice::from_init_mut methods which safely create Uninit slice from provided slice of maybe uninitialised or initialised memory. In addition, add `From<&mut [T]>` implementations (for `T=u8` and `T=MaybeUninit<u8>`) which do conversion from slice to UninitSlice. Closes: tokio-rs#552
mina86
added a commit
to mina86/bytes
that referenced
this issue
Feb 9, 2023
Introduce UninitSlice::from_slice and UninitSlice::from_uninit_slice methods which safely create Uninit slice from provided slice of maybe uninitialised or initialised memory. In addition, add `From<&mut [T]>` implementations (for `T=u8` and `T=MaybeUninit<u8>`) which do conversion from slice to UninitSlice. Closes: tokio-rs#552
mina86
added a commit
to mina86/bytes
that referenced
this issue
Feb 9, 2023
Introduce UninitSlice::from_slice and UninitSlice::from_uninit_slice methods which safely create Uninit slice from provided slice of maybe uninitialised or initialised memory. In addition, add `From<&mut [T]>` implementations (for `T=u8` and `T=MaybeUninit<u8>`) which do conversion from slice to UninitSlice. Closes: tokio-rs#552
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When implementing
BufMut
theBufMut::chunk_mut
method requires you to return anUninitSlice
instance.As
UninitSlice
only has the unsafefrom_raw_parts()
constructor, this means that even if your slice is definitely already initiated you still need to write unsafe code to return this slice.This isn't great, and it would be nice to have a way to safely create a UninitSlice from a slice of already initiated data.
The text was updated successfully, but these errors were encountered: