Skip to content

Commit 2b48b47

Browse files
committed
Box::leak - improve documentation
1 parent 360ce78 commit 2b48b47

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/liballoc/boxed.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -365,14 +365,15 @@ impl<T: ?Sized> Box<T> {
365365
unsafe { mem::transmute(b) }
366366
}
367367

368-
/// Consumes and leaks the `Box`, returning a static reference,
369-
/// `&'static T`.
368+
/// Consumes and leaks the `Box`, returning a static mutable reference,
369+
/// `&'static mut T`.
370370
///
371371
/// This function is mainly useful for data that lives for the remainder of
372-
/// the programs life. Dropping the returned reference will cause a memory
372+
/// the program's life. Dropping the returned reference will cause a memory
373373
/// leak. If this is not acceptable, the reference should first be wrapped
374-
/// with the [`Box::from_raw`] function producing a `Box` which can then be
375-
/// dropped which will properly destroy `T` and release the memory.
374+
/// with the [`Box::from_raw`] function producing a `Box`. This `Box` can
375+
/// then be dropped which will properly destroy `T` and release the
376+
/// allocated memory.
376377
///
377378
/// Note: this is an associated function, which means that you have
378379
/// to call it as `Box::leak(b)` instead of `b.leak()`. This

0 commit comments

Comments
 (0)