-
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
Rename UninitSlice constructors for consistency with ReadBuf #599
Conversation
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.
Uh, sorry, looks like I added pending comments but then forgot to actually send them.
tokio::io::ReadBuf uses names `new` and `uninit` for its constructors. For consistency with that, rename recently introduced UninitSlice constructors to match those names.
pub fn from_uninit_slice(slice: &mut [MaybeUninit<u8>]) -> &mut UninitSlice { | ||
unsafe { &mut *(slice as *mut [MaybeUninit<u8>] as *mut UninitSlice) } | ||
} | ||
|
||
fn from_uninit_slice_ref(slice: &[MaybeUninit<u8>]) -> &UninitSlice { | ||
unsafe { &*(slice as *const [MaybeUninit<u8>] as *const UninitSlice) } | ||
pub fn new(slice: &mut [u8]) -> &mut UninitSlice { | ||
unsafe { &mut *(slice as *mut [u8] as *mut [MaybeUninit<u8>] as *mut UninitSlice) } | ||
} | ||
|
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 guess the only reason this isn't a breaking change is that we haven't yet released the from_uninit_slice
method.
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.
Right. v1.4.0 had only from_raw_parts_mut
public constructor and
it’s not changed. from_slice
is changed but it’s pub(crate)
so it
doesn’t affect the API.
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.
Thanks.
tokio::io::ReadBuf uses names
new
anduninit
for itsconstructors. For consistency with that, rename recently
introduced UninitSlice constructors to match those names.