Skip to content

Commit

Permalink
Indicate how to move value out of Box in docs.
Browse files Browse the repository at this point in the history
Fixes #53634.
  • Loading branch information
frewsxcv committed Sep 29, 2018
1 parent 5c875d9 commit 8d10f96
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/liballoc/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,18 @@
//!
//! # Examples
//!
//! Creating a box:
//! Move a value from the stack to the heap by creating a [`Box`]:
//!
//! ```
//! let x = Box::new(5);
//! let val: u8 = 5;
//! let boxed: Box<u8> = Box::new(val);
//! ```
//!
//! Move a value from a [`Box`] back to the stack by [dereferencing]:
//!
//! ```
//! let boxed: Box<u8> = Box::new(5);
//! let val: u8 = *boxed;
//! ```
//!
//! Creating a recursive data structure:
Expand Down Expand Up @@ -52,6 +60,9 @@
//! elements are in the list, and so we don't know how much memory to allocate
//! for a `Cons`. By introducing a `Box`, which has a defined size, we know how
//! big `Cons` needs to be.
//!
//! [dereferencing]: ../../std/ops/trait.Deref.html
//! [`Box`]: struct.Box.html
#![stable(feature = "rust1", since = "1.0.0")]

Expand Down

0 comments on commit 8d10f96

Please sign in to comment.