pub trait Stateful<Q>where
Q: RawState,{
type State: StateRepr<Item = Q>;
// Required methods
fn state(&self) -> &Self::State;
fn state_mut(&mut self) -> &mut Self::State;
// Provided methods
fn set_state(&mut self, state: Self::State) -> &mut Self { ... }
fn replace_state(&mut self, state: Self::State) -> Self::State { ... }
fn swap_state(&mut self, state: &mut Self::State) { ... }
fn take_state(&mut self) -> Self::State
where Self::State: Default { ... }
}
Expand description
Stateful
is a trait establishing a common interface for all types that are state-aware.
Required Associated Types§
Required Methods§
Provided Methods§
fn set_state(&mut self, state: Self::State) -> &mut Self
Sourcefn replace_state(&mut self, state: Self::State) -> Self::State
fn replace_state(&mut self, state: Self::State) -> Self::State
replace
the current state with the given value and return the
old state.
Sourcefn swap_state(&mut self, state: &mut Self::State)
fn swap_state(&mut self, state: &mut Self::State)
swap
the current state with another of the same type.
fn take_state(&mut self) -> Self::State
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.