Skip to content

Commit 4863455

Browse files
committed
into_inner to associated function
1 parent c94b3f1 commit 4863455

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

src/libcore/mem.rs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -779,18 +779,35 @@ pub union ManuallyDrop<T>{ value: T }
779779

780780
impl<T> ManuallyDrop<T> {
781781
/// Wrap a value to be manually dropped.
782+
///
783+
/// # Examples
784+
///
785+
/// ```rust
786+
/// # #![feature(manually_drop)]
787+
/// use std::mem::ManuallyDrop;
788+
/// ManuallyDrop::new(Box::new(()));
789+
/// ```
782790
#[unstable(feature = "manually_drop", issue = "40673")]
783791
#[inline]
784792
pub fn new(value: T) -> ManuallyDrop<T> {
785793
ManuallyDrop { value: value }
786794
}
787795

788796
/// Extract the value from the ManuallyDrop container.
797+
///
798+
/// # Examples
799+
///
800+
/// ```rust
801+
/// # #![feature(manually_drop)]
802+
/// use std::mem::ManuallyDrop;
803+
/// let x = ManuallyDrop::new(Box::new(()));
804+
/// let _: Box<()> = ManuallyDrop::into_inner(x);
805+
/// ```
789806
#[unstable(feature = "manually_drop", issue = "40673")]
790807
#[inline]
791-
pub fn into_inner(self) -> T {
808+
pub fn into_inner(slot: ManuallyDrop<T>) -> T {
792809
unsafe {
793-
self.value
810+
slot.value
794811
}
795812
}
796813

0 commit comments

Comments
 (0)