diff options
| author | Raekye <Raekye@users.noreply.github.com> | 2022-04-15 21:21:02 -0400 |
|---|---|---|
| committer | Raekye <Raekye@users.noreply.github.com> | 2022-04-15 21:21:02 -0400 |
| commit | d5f96e6adea2532f3eba674b366cd2d71835b70b (patch) | |
| tree | 889b780f50cc954eb22c07e406441652767a4d36 | |
| parent | 3f391b84552f210adec7893b50c5da74f9362ae4 (diff) | |
| download | rust-d5f96e6adea2532f3eba674b366cd2d71835b70b.tar.gz rust-d5f96e6adea2532f3eba674b366cd2d71835b70b.zip | |
Change `as_uninit_*` methods on `NonNull` from taking `self` by
reference to taking `self` by value. This is consistent with the methods of the same names on primitive pointers. The returned lifetime was already previously unbounded.
| -rw-r--r-- | library/core/src/ptr/non_null.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/library/core/src/ptr/non_null.rs b/library/core/src/ptr/non_null.rs index 6f402924e75..2618cef3608 100644 --- a/library/core/src/ptr/non_null.rs +++ b/library/core/src/ptr/non_null.rs @@ -124,7 +124,7 @@ impl<T: Sized> NonNull<T> { #[must_use] #[unstable(feature = "ptr_as_uninit", issue = "75402")] #[rustc_const_unstable(feature = "const_ptr_as_ref", issue = "91822")] - pub const unsafe fn as_uninit_ref<'a>(&self) -> &'a MaybeUninit<T> { + pub const unsafe fn as_uninit_ref<'a>(self) -> &'a MaybeUninit<T> { // SAFETY: the caller must guarantee that `self` meets all the // requirements for a reference. unsafe { &*self.cast().as_ptr() } @@ -158,7 +158,7 @@ impl<T: Sized> NonNull<T> { #[must_use] #[unstable(feature = "ptr_as_uninit", issue = "75402")] #[rustc_const_unstable(feature = "const_ptr_as_ref", issue = "91822")] - pub const unsafe fn as_uninit_mut<'a>(&mut self) -> &'a mut MaybeUninit<T> { + pub const unsafe fn as_uninit_mut<'a>(self) -> &'a mut MaybeUninit<T> { // SAFETY: the caller must guarantee that `self` meets all the // requirements for a reference. unsafe { &mut *self.cast().as_ptr() } @@ -592,7 +592,7 @@ impl<T> NonNull<[T]> { #[must_use] #[unstable(feature = "ptr_as_uninit", issue = "75402")] #[rustc_const_unstable(feature = "const_ptr_as_ref", issue = "91822")] - pub const unsafe fn as_uninit_slice<'a>(&self) -> &'a [MaybeUninit<T>] { + pub const unsafe fn as_uninit_slice<'a>(self) -> &'a [MaybeUninit<T>] { // SAFETY: the caller must uphold the safety contract for `as_uninit_slice`. unsafe { slice::from_raw_parts(self.cast().as_ptr(), self.len()) } } @@ -655,7 +655,7 @@ impl<T> NonNull<[T]> { #[must_use] #[unstable(feature = "ptr_as_uninit", issue = "75402")] #[rustc_const_unstable(feature = "const_ptr_as_ref", issue = "91822")] - pub const unsafe fn as_uninit_slice_mut<'a>(&self) -> &'a mut [MaybeUninit<T>] { + pub const unsafe fn as_uninit_slice_mut<'a>(self) -> &'a mut [MaybeUninit<T>] { // SAFETY: the caller must uphold the safety contract for `as_uninit_slice_mut`. unsafe { slice::from_raw_parts_mut(self.cast().as_ptr(), self.len()) } } |
