about summary refs log tree commit diff
path: root/src/liballoc
diff options
context:
space:
mode:
authorMazdak <twingoow@gmail.com>2017-11-09 23:25:32 +0100
committerMazdak <twingoow@gmail.com>2017-11-09 23:25:32 +0100
commitdabb0c6605d2afb96892f7a3dad64b13c934de74 (patch)
tree9d495aaf9a68c38d3daf13c2415f7d9754ee6f74 /src/liballoc
parent79f62cb4d36e77c041fbed60ee0dde2535b9a946 (diff)
downloadrust-dabb0c6605d2afb96892f7a3dad64b13c934de74.tar.gz
rust-dabb0c6605d2afb96892f7a3dad64b13c934de74.zip
Box::leak - relaxed constraints wrt. lifetimes
Diffstat (limited to 'src/liballoc')
-rw-r--r--src/liballoc/boxed.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs
index ccaa4d497d4..58e5c4d66e4 100644
--- a/src/liballoc/boxed.rs
+++ b/src/liballoc/boxed.rs
@@ -390,7 +390,7 @@ impl<T: ?Sized> Box<T> {
     ///
     /// fn main() {
     ///     let x = Box::new(41);
-    ///     let static_ref = Box::leak(x);
+    ///     let static_ref: &'static mut usize = Box::leak(x);
     ///     *static_ref += 1;
     ///     assert_eq!(*static_ref, 42);
     /// }
@@ -411,7 +411,7 @@ impl<T: ?Sized> Box<T> {
     #[unstable(feature = "box_leak", reason = "needs an FCP to stabilize",
                issue = "0")]
     #[inline]
-    pub fn leak(b: Box<T>) -> &'static mut T {
+    pub fn leak<'a, T: 'a>(b: Box<T>) -> &'a mut T {
         unsafe { &mut *Box::into_raw(b) }
     }
 }