File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 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> {
973973 pub fn into_inner ( slot : ManuallyDrop < T > ) -> T {
974974 slot. value
975975 }
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+ }
976996}
977997
978998impl < T : ?Sized > ManuallyDrop < T > {
You can’t perform that action at this time.
0 commit comments