@@ -87,27 +87,28 @@ impl<T> ManuallyDrop<T> {
87
87
slot. value
88
88
}
89
89
90
- /// Takes the contained value out.
90
+ /// Takes the value from the `ManuallyDrop<T>` container out.
91
91
///
92
92
/// This method is primarily intended for moving out values in drop.
93
93
/// Instead of using [`ManuallyDrop::drop`] to manually drop the value,
94
94
/// you can use this method to take the value and use it however desired.
95
- /// `Drop` will be invoked on the returned value following normal end-of-scope rules.
96
95
///
97
- /// If you have ownership of the container, you can use [`ManuallyDrop::into_inner`] instead.
96
+ /// Whenever possible, it is preferrable to use [`into_inner`][`ManuallyDrop::into_inner`]
97
+ /// instead, which prevents duplicating the content of the `ManuallyDrop<T>`.
98
98
///
99
99
/// # Safety
100
100
///
101
- /// This function semantically moves out the contained value without preventing further usage.
102
- /// It is up to the user of this method to ensure that this container is not used again.
101
+ /// This function semantically moves out the contained value without preventing further usage,
102
+ /// leaving the state of this container unchanged.
103
+ /// It is your responsibility to ensure that this `ManuallyDrop` is not used again.
103
104
///
104
105
/// [`ManuallyDrop::drop`]: #method.drop
105
106
/// [`ManuallyDrop::into_inner`]: #method.into_inner
106
107
#[ must_use = "if you don't need the value, you can use `ManuallyDrop::drop` instead" ]
107
- #[ unstable ( feature = "manually_drop_take" , issue = "55422 " ) ]
108
+ #[ stable ( feature = "manually_drop_take" , since = "1.42.0 " ) ]
108
109
#[ inline]
109
110
pub unsafe fn take ( slot : & mut ManuallyDrop < T > ) -> T {
110
- ManuallyDrop :: into_inner ( ptr:: read ( slot) )
111
+ ptr:: read ( & slot. value )
111
112
}
112
113
}
113
114
0 commit comments