Crate take_mut [] [src]

This crate provides (at this time) a single function, 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 exited, as there's no valid T to put back into the &mut T.

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.

Functions

take

Allows use of a value pointed to by &mut T as though it was owned, as long as a T is made available afterwards.