Open
Description
It is possible to write a function to temporarily take, by value, a T
out of a &mut T
, replacing it by the end of the closure. Panics can be handled by killing the process. Crate to do this: https://github.com/Sgeo/take_mut/tree/v0.1.3 , take_mut::take
.
This might be reasonable to include in std::mem
, possibly under a different name. It's a function that effectively extends what it's possible to do with a &mut T
in safe code, similarly to std::mem::swap
and std::mem::replace
.
Drawbacks include that we might not want to encourage use of functions that, in the worst case, do things more extreme than panicking (exiting or aborting the process).
More bikeshedding opportunities on whether it should exit or abort on panic,