diff options
| author | Simon Sapin <simon.sapin@exyr.org> | 2017-12-27 22:53:27 +0100 |
|---|---|---|
| committer | Simon Sapin <simon.sapin@exyr.org> | 2018-01-20 11:09:23 +0100 |
| commit | 8ef5e549c3cec025c6b7c37931bddd68f2fcab4a (patch) | |
| tree | 1c5ccef9003a57b58aeb297e5d37c0d863c9a472 /src/liballoc | |
| parent | 1772fa2aa1262e5efae8172bbd9154a937269eb7 (diff) | |
| download | rust-8ef5e549c3cec025c6b7c37931bddd68f2fcab4a.tar.gz rust-8ef5e549c3cec025c6b7c37931bddd68f2fcab4a.zip | |
Remove `Box::from_non_null_raw`
Per https://github.com/rust-lang/rust/pull/46952#issuecomment-353956225
Diffstat (limited to 'src/liballoc')
| -rw-r--r-- | src/liballoc/boxed.rs | 38 |
1 files changed, 3 insertions, 35 deletions
diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index a1563483f1e..60998bc677b 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -272,34 +272,6 @@ impl<T: ?Sized> Box<T> { Box(Unique::new_unchecked(raw)) } - /// Constructs a `Box` from a `NonNull<T>` pointer. - /// - /// After calling this function, the memory is owned by a `Box` and `T` can - /// then be destroyed and released upon drop. - /// - /// # Safety - /// - /// A `NonNull<T>` can be safely created via [`NonNull::new`] and thus doesn't - /// necessarily own the data pointed to nor is the data guaranteed to live - /// as long as the pointer. - /// - /// [`NonNull::new`]: ../../core/ptr/struct.NonNull.html#method.new - /// - /// # Examples - /// - /// ``` - /// fn main() { - /// let x = Box::new(5); - /// let ptr = Box::into_non_null_raw(x); - /// let x = unsafe { Box::from_non_null_raw(ptr) }; - /// } - /// ``` - #[stable(feature = "nonnull", since = "1.24.0")] - #[inline] - pub unsafe fn from_non_null_raw(u: NonNull<T>) -> Self { - Box(u.into()) - } - /// Consumes the `Box`, returning the wrapped raw pointer. /// /// After calling this function, the caller is responsible for the @@ -331,19 +303,15 @@ impl<T: ?Sized> Box<T> { /// After calling this function, the caller is responsible for the /// memory previously managed by the `Box`. In particular, the /// caller should properly destroy `T` and release the memory. The - /// proper way to do so is to either convert the `NonNull<T>` pointer: - /// - /// - Into a `Box` with the [`Box::from_non_null_raw`] function. - /// - /// - Into a raw pointer and back into a `Box` with the [`Box::from_raw`] - /// function. + /// proper way to do so is to convert the `NonNull<T>` pointer + /// into a raw pointer and back into a `Box` with the [`Box::from_raw`] + /// function. /// /// Note: this is an associated function, which means that you have /// to call it as `Box::into_non_null_raw(b)` /// instead of `b.into_non_null_raw()`. This /// is so that there is no conflict with a method on the inner type. /// - /// [`Box::from_non_null_raw`]: struct.Box.html#method.from_non_null_raw /// [`Box::from_raw`]: struct.Box.html#method.from_raw /// /// # Examples |
