File tree 1 file changed +20
-0
lines changed
1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -973,6 +973,26 @@ impl<T> ManuallyDrop<T> {
973
973
pub fn into_inner ( slot : ManuallyDrop < T > ) -> T {
974
974
slot. value
975
975
}
976
+
977
+ /// Takes the contained value out.
978
+ ///
979
+ /// This method is primarily intended for moving out values in drop.
980
+ /// Instead of using [`ManuallyDrop::drop`] to manually drop the value,
981
+ /// you can use this method to take the value and use it however desired.
982
+ /// `Drop` will be invoked on the returned value following normal end-of-scope rules.
983
+ ///
984
+ /// If you have ownership of the container, you can use [`ManuallyDrop::into_inner`] instead.
985
+ ///
986
+ /// # Safety
987
+ ///
988
+ /// This function semantically moves out the contained value without preventing further usage.
989
+ /// It is up to the user of this method to ensure that this container is not used again.
990
+ #[ must_use = "if you don't need the value, you can use `ManuallyDrop::drop` instead" ]
991
+ #[ unstable( feature = "manually_drop_take" , issue = "55422" ) ]
992
+ #[ inline]
993
+ pub unsafe fn take ( slot : & mut ManuallyDrop < T > ) -> T {
994
+ ManuallyDrop :: into_inner ( ptr:: read ( slot) )
995
+ }
976
996
}
977
997
978
998
impl < T : ?Sized > ManuallyDrop < T > {
You can’t perform that action at this time.
0 commit comments