Box::leak - improve documentation
This commit is contained in:
@@ -365,14 +365,15 @@ impl<T: ?Sized> Box<T> {
|
|||||||
unsafe { mem::transmute(b) }
|
unsafe { mem::transmute(b) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Consumes and leaks the `Box`, returning a static reference,
|
/// Consumes and leaks the `Box`, returning a static mutable reference,
|
||||||
/// `&'static T`.
|
/// `&'static mut T`.
|
||||||
///
|
///
|
||||||
/// This function is mainly useful for data that lives for the remainder of
|
/// This function is mainly useful for data that lives for the remainder of
|
||||||
/// the programs life. Dropping the returned reference will cause a memory
|
/// the program's life. Dropping the returned reference will cause a memory
|
||||||
/// leak. If this is not acceptable, the reference should first be wrapped
|
/// leak. If this is not acceptable, the reference should first be wrapped
|
||||||
/// with the [`Box::from_raw`] function producing a `Box` which can then be
|
/// with the [`Box::from_raw`] function producing a `Box`. This `Box` can
|
||||||
/// dropped which will properly destroy `T` and release the memory.
|
/// then be dropped which will properly destroy `T` and release the
|
||||||
|
/// allocated memory.
|
||||||
///
|
///
|
||||||
/// Note: this is an associated function, which means that you have
|
/// Note: this is an associated function, which means that you have
|
||||||
/// to call it as `Box::leak(b)` instead of `b.leak()`. This
|
/// to call it as `Box::leak(b)` instead of `b.leak()`. This
|
||||||
|
|||||||
Reference in New Issue
Block a user