Expand description
This crate provides several functions for handling &mut T including take().
take() allows for taking T out of a &mut T, doing anything with it including consuming it, and producing another T to put back in the &mut T.
During take(), if a panic occurs, the entire process will be aborted, as there’s no valid T to put back into the &mut T.
Use take_or_recover() to replace the &mut T with a recovery value before continuing the panic.
Contrast with std::mem::replace(), which allows for putting a different T into a &mut T, but requiring the new T to be available before being able to consume the old T.
Modules§
- scoped
- This module provides a scoped API, allowing for taking an arbitrary number of
&mut TintoTwithin one closure. The references are all required to outlive the closure.
Functions§
- take
- Allows use of a value pointed to by
&mut Tas though it was owned, as long as aTis made available afterwards. - take_
or_ recover - Allows use of a value pointed to by
&mut Tas though it was owned, as long as aTis made available afterwards.