We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 79f62cb commit dabb0c6Copy full SHA for dabb0c6
src/liballoc/boxed.rs
@@ -390,7 +390,7 @@ impl<T: ?Sized> Box<T> {
390
///
391
/// fn main() {
392
/// let x = Box::new(41);
393
- /// let static_ref = Box::leak(x);
+ /// let static_ref: &'static mut usize = Box::leak(x);
394
/// *static_ref += 1;
395
/// assert_eq!(*static_ref, 42);
396
/// }
@@ -411,7 +411,7 @@ impl<T: ?Sized> Box<T> {
411
#[unstable(feature = "box_leak", reason = "needs an FCP to stabilize",
412
issue = "0")]
413
#[inline]
414
- pub fn leak(b: Box<T>) -> &'static mut T {
+ pub fn leak<'a, T: 'a>(b: Box<T>) -> &'a mut T {
415
unsafe { &mut *Box::into_raw(b) }
416
}
417
0 commit comments