From: Mazdak Date: Thu, 9 Nov 2017 22:39:18 +0000 (+0100) Subject: Box::leak - made an oops, fixed now =) X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=46800ab135f70d8869e58e4163730ba2b38006ba;p=rust.git Box::leak - made an oops, fixed now =) --- diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index 49f5f68fa77..c76f51057ff 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -411,7 +411,10 @@ pub fn into_unique(b: Box) -> Unique { #[unstable(feature = "box_leak", reason = "needs an FCP to stabilize", issue = "0")] #[inline] - pub fn leak<'a, T: 'a>(b: Box) -> &'a mut T { + pub fn leak<'a>(b: Box) -> &'a mut T + where + T: 'a // Technically not needed, but kept to be explicit. + { unsafe { &mut *Box::into_raw(b) } } }