Skip to content

Commit

Permalink
Rollup merge of rust-lang#48110 - Centril:stabilize/box_leak, r=alexc…
Browse files Browse the repository at this point in the history
…richton

Stabilize Box::leak

Stabilizes the following:
+ `Box::leak` (`box_leak`, in nightly since 2017-11-23)

cc rust-lang#46179

 r? @rust-lang/libs
  • Loading branch information
Manishearth authored Feb 24, 2018
2 parents edfdfc2 + 4861603 commit dd890d8
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions src/liballoc/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,6 @@ impl<T: ?Sized> Box<T> {
/// Simple usage:
///
/// ```
/// #![feature(box_leak)]
///
/// fn main() {
/// let x = Box::new(41);
/// let static_ref: &'static mut usize = Box::leak(x);
Expand All @@ -372,17 +370,14 @@ impl<T: ?Sized> Box<T> {
/// Unsized data:
///
/// ```
/// #![feature(box_leak)]
///
/// fn main() {
/// let x = vec![1, 2, 3].into_boxed_slice();
/// let static_ref = Box::leak(x);
/// static_ref[0] = 4;
/// assert_eq!(*static_ref, [4, 2, 3]);
/// }
/// ```
#[unstable(feature = "box_leak", reason = "needs an FCP to stabilize",
issue = "46179")]
#[stable(feature = "box_leak", since = "1.26.0")]
#[inline]
pub fn leak<'a>(b: Box<T>) -> &'a mut T
where
Expand Down

0 comments on commit dd890d8

Please sign in to comment.