]> git.lizzy.rs Git - rust.git/commitdiff
Box::leak - fixed bug in documentation
authorMazdak <twingoow@gmail.com>
Wed, 8 Nov 2017 23:15:07 +0000 (00:15 +0100)
committerMazdak <twingoow@gmail.com>
Wed, 8 Nov 2017 23:15:07 +0000 (00:15 +0100)
src/liballoc/boxed.rs

index 7c3452cc753f75e207e4d735ae76307aa7c0de0b..ccaa4d497d45c7cfb40ce900204f9acea62841be 100644 (file)
@@ -386,19 +386,27 @@ pub fn into_unique(b: Box<T>) -> Unique<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")]