take_mut
Rust API reference for the module take_mut.
Public API
Function: take
Canonical path: take_mut::take
Declared in: src/lib.rs
Signature
pub fn take<T, F>(mut_ref: &mut T, closure: F)
where F: FnOnce(T) -> T {}
Summary
Allows use of a value pointed to by `&mut T` as though it was owned, as long as a `T` is made available afterwards.
Behavior
The closure must return a valid T.
Parameters
- mut_ref: A mutable reference to a value of type T.
- closure: A closure that takes the owned value T and returns a new value of type T.
Function: take_or_recover
Canonical path: take_mut::take_or_recover
Declared in: src/lib.rs
Signature
pub fn take_or_recover<T, F>(mut_ref: &mut T, recover: T, closure: F)
where F: FnOnce(T) -> T {}
Summary
Allows use of a value pointed to by `&mut T` as though it was owned, as long as a `T` is made available afterwards.
Behavior
The closure must return a valid T.
Parameters
- mut_ref: A mutable reference to a value of type T.
- recover: A fallback value of type T used to replace the content of mut_ref if the closure panics.
- closure: A closure that takes the owned value T and returns a new value of type T.