take_mut
take_mut copied to clipboard
Intended to allow taking a T from a &mut T temporarily
In keeping with Rust's expression-oriented nature, it would be nice to have a variant of `take()` that allows returning some value from the closure. A sort of linear state monad....
The use of std::process::catch_unwind and abort makes this crate (and all that depend on it) unusable for embedded systems. The same guarantee the "catch_unwind or abort" mechanism gives can be...
The thing can have a destructor (because the closure might capture things that have destructor themselves) and not running it might leak resources.
This small change saves 4 copies of T in my debug tests, even preventing a stack overflow in my user code. Only makes a difference when building in debug mode...
These changes add `take_no_exit()` function which uses sentinel value instead of exiting.