Skip to content
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

Merged
merged 1 commit into from Jun 20, 2023

Conversation

mina86
Copy link
Contributor

@mina86 mina86 commented Feb 11, 2023

tokio::io::ReadBuf uses names new and uninit for its
constructors. For consistency with that, rename recently
introduced UninitSlice constructors to match those names.

src/buf/uninit_slice.rs Outdated Show resolved Hide resolved
src/buf/uninit_slice.rs Outdated Show resolved Hide resolved
Copy link
Contributor Author

@mina86 mina86 left a 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.

src/buf/uninit_slice.rs Outdated Show resolved Hide resolved
tokio::io::ReadBuf uses names `new` and `uninit` for its constructors.
For consistency with that, rename recently introduced UninitSlice
constructors to match those names.
Comment on lines -40 to 39
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) }
}

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

@Darksonn Darksonn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

@Darksonn Darksonn merged commit 64c4fa2 into tokio-rs:master Jun 20, 2023
15 checks passed
@Darksonn Darksonn mentioned this pull request Sep 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants