Transitionable
Allows transitioning a T from one state to the next by value, even when you only have access to a mutable reference &mut T.
use Transitionable;
// Imagine this is your `T` type.
// Imagine some other code forces you to work with `&mut`.
let t = &mut new;
// Despite our `Transitionable` being behind an `&mut`, we can consume the contained `State` by value and produce a new `State`.
transition;
// Transitionable acts like a smart pointer; we can dereference it and verify that the value has indeed transitioned to a new state.
assert!;
These crates offer similar functionality:
takeableis similar but does not optimize whenpanic = "abort".replace_withcan be used when you can not wrap yourTin another type but has different performance characteristics and the optimized version is behind anunsafefunction.
View the documentation for more details.