@@ -272,34 +272,6 @@ impl<T: ?Sized> Box<T> {
272
272
Box ( Unique :: new_unchecked ( raw) )
273
273
}
274
274
275
- /// Constructs a `Box` from a `NonNull<T>` pointer.
276
- ///
277
- /// After calling this function, the memory is owned by a `Box` and `T` can
278
- /// then be destroyed and released upon drop.
279
- ///
280
- /// # Safety
281
- ///
282
- /// A `NonNull<T>` can be safely created via [`NonNull::new`] and thus doesn't
283
- /// necessarily own the data pointed to nor is the data guaranteed to live
284
- /// as long as the pointer.
285
- ///
286
- /// [`NonNull::new`]: ../../core/ptr/struct.NonNull.html#method.new
287
- ///
288
- /// # Examples
289
- ///
290
- /// ```
291
- /// fn main() {
292
- /// let x = Box::new(5);
293
- /// let ptr = Box::into_non_null_raw(x);
294
- /// let x = unsafe { Box::from_non_null_raw(ptr) };
295
- /// }
296
- /// ```
297
- #[ stable( feature = "nonnull" , since = "1.24.0" ) ]
298
- #[ inline]
299
- pub unsafe fn from_non_null_raw ( u : NonNull < T > ) -> Self {
300
- Box ( u. into ( ) )
301
- }
302
-
303
275
/// Consumes the `Box`, returning the wrapped raw pointer.
304
276
///
305
277
/// After calling this function, the caller is responsible for the
@@ -331,19 +303,15 @@ impl<T: ?Sized> Box<T> {
331
303
/// After calling this function, the caller is responsible for the
332
304
/// memory previously managed by the `Box`. In particular, the
333
305
/// caller should properly destroy `T` and release the memory. The
334
- /// proper way to do so is to either convert the `NonNull<T>` pointer:
335
- ///
336
- /// - Into a `Box` with the [`Box::from_non_null_raw`] function.
337
- ///
338
- /// - Into a raw pointer and back into a `Box` with the [`Box::from_raw`]
339
- /// function.
306
+ /// proper way to do so is to convert the `NonNull<T>` pointer
307
+ /// into a raw pointer and back into a `Box` with the [`Box::from_raw`]
308
+ /// function.
340
309
///
341
310
/// Note: this is an associated function, which means that you have
342
311
/// to call it as `Box::into_non_null_raw(b)`
343
312
/// instead of `b.into_non_null_raw()`. This
344
313
/// is so that there is no conflict with a method on the inner type.
345
314
///
346
- /// [`Box::from_non_null_raw`]: struct.Box.html#method.from_non_null_raw
347
315
/// [`Box::from_raw`]: struct.Box.html#method.from_raw
348
316
///
349
317
/// # Examples
0 commit comments