StateRepr

Trait StateRepr 

Source
pub trait StateRepr<U>
where U: RawState,
{ type Repr<_V: RawState>; // Required methods fn get(&self) -> &U; fn get_mut(&mut self) -> &mut U; fn view(&self) -> Self::Repr<&U>; fn view_mut(&mut self) -> Self::Repr<&mut U>; // Provided methods fn replace(&mut self, value: U) -> U { ... } fn set(&mut self, value: U) { ... } fn swap(&mut self, other: &mut Self) { ... } fn take(&mut self) -> U where U: Default { ... } }
Expand description

The StateRepr trait defines a common interface for any implemented representations of state.

Required Associated Types§

Required Methods§

Source

fn get(&self) -> &U

return a reference to the underlying state

Source

fn get_mut(&mut self) -> &mut U

return a mutable reference to the underlying state

Source

fn view(&self) -> Self::Repr<&U>

returns a view of the representation using a reference to the current value

Source

fn view_mut(&mut self) -> Self::Repr<&mut U>

returns a view of the representation containing a mutable reference to the current value

Provided Methods§

Source

fn replace(&mut self, value: U) -> U

replace the inner value with another value, returning the old value

Source

fn set(&mut self, value: U)

update the inner value

Source

fn swap(&mut self, other: &mut Self)

swap the inner value with another value

Source

fn take(&mut self) -> U
where U: Default,

take the inner value, leaving a default value in its place

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.

Implementors§

Source§

impl<Q> StateRepr<Q> for State<Q>
where Q: RawState,

Source§

type Repr<_V: RawState> = State<_V>