about summary refs log tree commit diff
path: root/src/liballoc
diff options
context:
space:
mode:
authorMazdak <twingoow@gmail.com>2017-11-09 00:15:07 +0100
committerMazdak <twingoow@gmail.com>2017-11-09 00:15:07 +0100
commit79f62cb4d36e77c041fbed60ee0dde2535b9a946 (patch)
tree3cc4385fd638d20d92c07b1f66af8047bced8a0b /src/liballoc
parent2b48b4779ecde356b701a1b12a602443a78d0e6d (diff)
downloadrust-79f62cb4d36e77c041fbed60ee0dde2535b9a946.tar.gz
rust-79f62cb4d36e77c041fbed60ee0dde2535b9a946.zip
Box::leak - fixed bug in documentation
Diffstat (limited to 'src/liballoc')
-rw-r--r--src/liballoc/boxed.rs24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs
index 7c3452cc753..ccaa4d497d4 100644
--- a/src/liballoc/boxed.rs
+++ b/src/liballoc/boxed.rs
@@ -386,19 +386,27 @@ impl<T: ?Sized> Box<T> {
     /// Simple usage:
     ///
     /// ```
-    /// let x = Box::new(41);
-    /// let static_ref = Box::leak(x);
-    /// *static_ref += 1;
-    /// assert_eq!(*static_ref, 42);
+    /// #![feature(box_leak)]
+    ///
+    /// fn main() {
+    ///     let x = Box::new(41);
+    ///     let static_ref = Box::leak(x);
+    ///     *static_ref += 1;
+    ///     assert_eq!(*static_ref, 42);
+    /// }
     /// ```
     ///
     /// Unsized data:
     ///
     /// ```
-    /// let x = vec![1, 2, 3].into_boxed_slice();
-    /// let static_ref = Box::leak(x);
-    /// static_ref[0] = 4;
-    /// assert_eq!(*static_ref, [4, 2, 3]);
+    /// #![feature(box_leak)]
+    ///
+    /// fn main() {
+    ///     let x = vec![1, 2, 3].into_boxed_slice();
+    ///     let static_ref = Box::leak(x);
+    ///     static_ref[0] = 4;
+    ///     assert_eq!(*static_ref, [4, 2, 3]);
+    /// }
     /// ```
     #[unstable(feature = "box_leak", reason = "needs an FCP to stabilize",
                issue = "0")]