File tree Expand file tree Collapse file tree 1 file changed +16
-8
lines changed Expand file tree Collapse file tree 1 file changed +16
-8
lines changed Original file line number Diff line number Diff line change @@ -386,19 +386,27 @@ impl<T: ?Sized> Box<T> {
386
386
/// Simple usage:
387
387
///
388
388
/// ```
389
- /// let x = Box::new(41);
390
- /// let static_ref = Box::leak(x);
391
- /// *static_ref += 1;
392
- /// assert_eq!(*static_ref, 42);
389
+ /// #![feature(box_leak)]
390
+ ///
391
+ /// fn main() {
392
+ /// let x = Box::new(41);
393
+ /// let static_ref = Box::leak(x);
394
+ /// *static_ref += 1;
395
+ /// assert_eq!(*static_ref, 42);
396
+ /// }
393
397
/// ```
394
398
///
395
399
/// Unsized data:
396
400
///
397
401
/// ```
398
- /// let x = vec![1, 2, 3].into_boxed_slice();
399
- /// let static_ref = Box::leak(x);
400
- /// static_ref[0] = 4;
401
- /// assert_eq!(*static_ref, [4, 2, 3]);
402
+ /// #![feature(box_leak)]
403
+ ///
404
+ /// fn main() {
405
+ /// let x = vec![1, 2, 3].into_boxed_slice();
406
+ /// let static_ref = Box::leak(x);
407
+ /// static_ref[0] = 4;
408
+ /// assert_eq!(*static_ref, [4, 2, 3]);
409
+ /// }
402
410
/// ```
403
411
#[ unstable( feature = "box_leak" , reason = "needs an FCP to stabilize" ,
404
412
issue = "0" ) ]
You can’t perform that action at this time.
0 commit comments