Skip to content

Commit dabb0c6

Browse files
committed
Box::leak - relaxed constraints wrt. lifetimes
1 parent 79f62cb commit dabb0c6

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/liballoc/boxed.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ impl<T: ?Sized> Box<T> {
390390
///
391391
/// fn main() {
392392
/// let x = Box::new(41);
393-
/// let static_ref = Box::leak(x);
393+
/// let static_ref: &'static mut usize = Box::leak(x);
394394
/// *static_ref += 1;
395395
/// assert_eq!(*static_ref, 42);
396396
/// }
@@ -411,7 +411,7 @@ impl<T: ?Sized> Box<T> {
411411
#[unstable(feature = "box_leak", reason = "needs an FCP to stabilize",
412412
issue = "0")]
413413
#[inline]
414-
pub fn leak(b: Box<T>) -> &'static mut T {
414+
pub fn leak<'a, T: 'a>(b: Box<T>) -> &'a mut T {
415415
unsafe { &mut *Box::into_raw(b) }
416416
}
417417
}

0 commit comments

Comments
 (0)