Skip to content

Commit

Permalink
into_inner to associated function
Browse files Browse the repository at this point in the history
  • Loading branch information
nagisa committed Apr 9, 2017
1 parent c94b3f1 commit 4863455
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/libcore/mem.rs
Expand Up @@ -779,18 +779,35 @@ pub union ManuallyDrop<T>{ value: T }

impl<T> ManuallyDrop<T> {
/// Wrap a value to be manually dropped.
///
/// # Examples
///
/// ```rust
/// # #![feature(manually_drop)]
/// use std::mem::ManuallyDrop;
/// ManuallyDrop::new(Box::new(()));
/// ```
#[unstable(feature = "manually_drop", issue = "40673")]
#[inline]
pub fn new(value: T) -> ManuallyDrop<T> {
ManuallyDrop { value: value }
}

/// Extract the value from the ManuallyDrop container.
///
/// # Examples
///
/// ```rust
/// # #![feature(manually_drop)]
/// use std::mem::ManuallyDrop;
/// let x = ManuallyDrop::new(Box::new(()));
/// let _: Box<()> = ManuallyDrop::into_inner(x);
/// ```
#[unstable(feature = "manually_drop", issue = "40673")]
#[inline]
pub fn into_inner(self) -> T {
pub fn into_inner(slot: ManuallyDrop<T>) -> T {
unsafe {
self.value
slot.value
}
}

Expand Down

0 comments on commit 4863455

Please sign in to comment.