about summary refs log tree commit diff
path: root/src/liballoc
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-10-01 10:16:00 +0000
committerbors <bors@rust-lang.org>2018-10-01 10:16:00 +0000
commit6188c58a55a27efac25f6e50a8e5f18c2650b60f (patch)
tree867c17d68b0dce674e3ed4905b07d726ec4171ce /src/liballoc
parentf55129d0037c112a80276ee1de0c2245ddc6462c (diff)
parent5b08200223d7307edca13a925a4ae58a68bc9872 (diff)
Auto merge of #54711 - kennytm:rollup, r=kennytm
Rollup of 13 pull requests

Successful merges:

 - #53784 (Document that slices cannot be larger than `isize::MAX` bytes)
 - #54308 (Better user experience when attempting to call associated functions with dot notation)
 - #54488 (in which we include attributes in unused `extern crate` suggestion spans)
 - #54544 (Indicate how to move value out of Box in docs.)
 - #54623 (Added help message for `impl_trait_in_bindings` feature gate)
 - #54641 (A few cleanups and minor improvements to rustc/infer)
 - #54656 (Correct doc for WorkQueue<T>::pop().)
 - #54674 (update miri)
 - #54676 (Remove `-Z disable_ast_check_for_mutation_in_guard`)
 - #54679 (Improve bug! message for impossible case in Relate)
 - #54681 (Rename sanitizer runtime libraries on OSX)
 - #54708 (Make ./x.py help <cmd> invoke ./x.py <cmd> -h on its own)
 - #54713 (Add nightly check for tool_lints warning)
Diffstat (limited to 'src/liballoc')
-rw-r--r--src/liballoc/boxed.rs15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs
index d4cca387f06..f989e701913 100644
--- a/src/liballoc/boxed.rs
+++ b/src/liballoc/boxed.rs
@@ -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:
@@ -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")]