#[repr(transparent)]pub struct State<Q = bool>(pub Q)
where
Q: ?Sized;Expand description
The State wrapper is a generic container used to denote objects being used as a
state in a Turing machine, finite-state machine, or similar computational model.
Tuple Fields§
§0: QImplementations§
Source§impl<Q> State<Q>
impl<Q> State<Q>
Sourcepub fn init<F>(f: F) -> State<Q>where
F: FnOnce() -> Q,
pub fn init<F>(f: F) -> State<Q>where
F: FnOnce() -> Q,
create a new state by invoking the given function and capturing its output.
Sourcepub const fn as_ptr(&self) -> *const Q
pub const fn as_ptr(&self) -> *const Q
returns a new instance of state with a raw pointer to the inner value.
Sourcepub const fn as_mut_ptr(&mut self) -> *mut Q
pub const fn as_mut_ptr(&mut self) -> *mut Q
returns a new instance of state with a mutable raw pointer to the inner value.
Sourcepub const fn get_mut(&mut self) -> &mut Q
pub const fn get_mut(&mut self) -> &mut Q
returns a mutable reference to the inner value of the state.
Sourcepub fn map<R, F>(self, f: F) -> State<R>where
F: FnOnce(Q) -> R,
pub fn map<R, F>(self, f: F) -> State<R>where
F: FnOnce(Q) -> R,
State::map applies the given function onto the inner value of the state, returning a new state with the result.
Sourcepub fn reset(&mut self) -> State<Q>where
Q: Default,
pub fn reset(&mut self) -> State<Q>where
Q: Default,
reset the state back to its logical default, returning the previous value.
Sourcepub const fn replace(&mut self, state: Q) -> Q
pub const fn replace(&mut self, state: Q) -> Q
replace the inner value of the state with the given state,
Sourcepub const fn swap(&mut self, other: &mut State<Q>)
pub const fn swap(&mut self, other: &mut State<Q>)
swap the inner value of the state with that of the given state.
Sourcepub fn take(&mut self) -> Qwhere
Q: Default,
pub fn take(&mut self) -> Qwhere
Q: Default,
take the inner value of the state, leaving the logical default in
its place
Sourcepub fn as_halt(&self) -> State<Halt<&Q>>where
Q: RawState,
pub fn as_halt(&self) -> State<Halt<&Q>>where
Q: RawState,
converts the current reference into a haltable state initialized with the current state
Sourcepub fn into_halt(self) -> State<Halt<Q>>where
Q: RawState,
pub fn into_halt(self) -> State<Halt<Q>>where
Q: RawState,
consumes the wrapper to create another, haltable state that is initialized with the current state
Sourcepub fn halt(self) -> State<Halt<Q>>where
Q: RawState,
pub fn halt(self) -> State<Halt<Q>>where
Q: RawState,
consumes the current state, returning a new one with a Halt
variant initialized with the current value.
Sourcepub const fn view_mut(&mut self) -> State<&mut Q>
pub const fn view_mut(&mut self) -> State<&mut Q>
returns a state with a mutable reference to the inner value.
Sourcepub fn get_inner_type_name(&self) -> &'static str
pub fn get_inner_type_name(&self) -> &'static str
returns the name of the generic inner type, Q.
Sourcepub const fn get_inner_type_id(&self) -> TypeIdwhere
Q: 'static,
pub const fn get_inner_type_id(&self) -> TypeIdwhere
Q: 'static,
returns the type id of the generic inner type, Q.
Source§impl<Q> State<Q>
Additional implementations for the State type enabled whenever the alloc feature is
toggled.
impl<Q> State<Q>
Additional implementations for the State type enabled whenever the alloc feature is
toggled.
Sourcepub fn as_any(&self) -> State<Box<dyn Any>>where
Q: Clone + 'static,
pub fn as_any(&self) -> State<Box<dyn Any>>where
Q: Clone + 'static,
Converts the inner type into a boxed “any” state, returning a new instance of state
Sourcepub fn into_any(self) -> State<Box<dyn Any>>where
Q: 'static,
pub fn into_any(self) -> State<Box<dyn Any>>where
Q: 'static,
Converts the inner type into a boxed “any” state, returning a new instance of state
convert the state into another instance by wrapping the inner value with an Arc.
returns a shared reference to the state.
Source§impl<Q> State<*mut Q>
impl<Q> State<*mut Q>
Sourcepub fn from_mut_ptr(ptr: *mut Q) -> State<*mut Q>
pub fn from_mut_ptr(ptr: *mut Q) -> State<*mut Q>
Creates a new instance of state with a mutable raw pointer to the inner value.
Source§impl<Q> State<MaybeUninit<Q>>
impl<Q> State<MaybeUninit<Q>>
Sourcepub const fn initialized(value: Q) -> State<MaybeUninit<Q>>
pub const fn initialized(value: Q) -> State<MaybeUninit<Q>>
Creates a new instance of state with an initialized inner value.
Sourcepub const fn uninit() -> State<MaybeUninit<Q>>
pub const fn uninit() -> State<MaybeUninit<Q>>
Creates a new instance of state with an uninitialized inner value.
Sourcepub unsafe fn assume_init(self) -> State<Q>
pub unsafe fn assume_init(self) -> State<Q>
Source§impl State<Box<dyn Any>>
impl State<Box<dyn Any>>
Sourcepub fn downcast<Q>(self) -> Result<State<Box<Q>>, StateError>where
Q: Any,
pub fn downcast<Q>(self) -> Result<State<Box<Q>>, StateError>where
Q: Any,
Attempts to downcast the state to a concrete type Q; returns an error if the state
is not of type Q.
Trait Implementations§
Source§impl<'a, _A, _B, _C> Add<&'a mut State<_B>> for State<_A>where
_A: Add<&'a mut _B, Output = _C>,
impl<'a, _A, _B, _C> Add<&'a mut State<_B>> for State<_A>where
_A: Add<&'a mut _B, Output = _C>,
Source§impl<'a, _A, _B, _C> Add<State<_B>> for &'a mut State<_A>where
&'a mut _A: Add<_B, Output = _C>,
impl<'a, _A, _B, _C> Add<State<_B>> for &'a mut State<_A>where
&'a mut _A: Add<_B, Output = _C>,
Source§impl<_A, _B> AddAssign<State<_B>> for State<_A>where
_A: AddAssign<_B>,
impl<_A, _B> AddAssign<State<_B>> for State<_A>where
_A: AddAssign<_B>,
Source§fn add_assign(&mut self, rhs: State<_B>)
fn add_assign(&mut self, rhs: State<_B>)
+= operation. Read moreSource§impl<'a, _A, _B, _C> BitAnd<&'a mut State<_B>> for State<_A>where
_A: BitAnd<&'a mut _B, Output = _C>,
impl<'a, _A, _B, _C> BitAnd<&'a mut State<_B>> for State<_A>where
_A: BitAnd<&'a mut _B, Output = _C>,
Source§impl<'a, _A, _B, _C> BitAnd<State<_B>> for &'a mut State<_A>where
&'a mut _A: BitAnd<_B, Output = _C>,
impl<'a, _A, _B, _C> BitAnd<State<_B>> for &'a mut State<_A>where
&'a mut _A: BitAnd<_B, Output = _C>,
Source§impl<_A, _B> BitAndAssign<State<_B>> for State<_A>where
_A: BitAndAssign<_B>,
impl<_A, _B> BitAndAssign<State<_B>> for State<_A>where
_A: BitAndAssign<_B>,
Source§fn bitand_assign(&mut self, rhs: State<_B>)
fn bitand_assign(&mut self, rhs: State<_B>)
&= operation. Read moreSource§impl<'a, _A, _B, _C> BitOr<&'a mut State<_B>> for State<_A>where
_A: BitOr<&'a mut _B, Output = _C>,
impl<'a, _A, _B, _C> BitOr<&'a mut State<_B>> for State<_A>where
_A: BitOr<&'a mut _B, Output = _C>,
Source§impl<'a, _A, _B, _C> BitOr<State<_B>> for &'a mut State<_A>where
&'a mut _A: BitOr<_B, Output = _C>,
impl<'a, _A, _B, _C> BitOr<State<_B>> for &'a mut State<_A>where
&'a mut _A: BitOr<_B, Output = _C>,
Source§impl<_A, _B> BitOrAssign<State<_B>> for State<_A>where
_A: BitOrAssign<_B>,
impl<_A, _B> BitOrAssign<State<_B>> for State<_A>where
_A: BitOrAssign<_B>,
Source§fn bitor_assign(&mut self, rhs: State<_B>)
fn bitor_assign(&mut self, rhs: State<_B>)
|= operation. Read moreSource§impl<'a, _A, _B, _C> BitXor<&'a mut State<_B>> for State<_A>where
_A: BitXor<&'a mut _B, Output = _C>,
impl<'a, _A, _B, _C> BitXor<&'a mut State<_B>> for State<_A>where
_A: BitXor<&'a mut _B, Output = _C>,
Source§impl<'a, _A, _B, _C> BitXor<State<_B>> for &'a mut State<_A>where
&'a mut _A: BitXor<_B, Output = _C>,
impl<'a, _A, _B, _C> BitXor<State<_B>> for &'a mut State<_A>where
&'a mut _A: BitXor<_B, Output = _C>,
Source§impl<_A, _B> BitXorAssign<State<_B>> for State<_A>where
_A: BitXorAssign<_B>,
impl<_A, _B> BitXorAssign<State<_B>> for State<_A>where
_A: BitXorAssign<_B>,
Source§fn bitxor_assign(&mut self, rhs: State<_B>)
fn bitxor_assign(&mut self, rhs: State<_B>)
^= operation. Read moreSource§impl<Q> BorrowMut<Q> for State<Q>
impl<Q> BorrowMut<Q> for State<Q>
Source§fn borrow_mut(&mut self) -> &mut Q
fn borrow_mut(&mut self) -> &mut Q
Source§impl<Q, A> BorrowMut<State<Q>> for Head<Q, A>where
Q: RawState,
impl<Q, A> BorrowMut<State<Q>> for Head<Q, A>where
Q: RawState,
Source§fn borrow_mut(&mut self) -> &mut State<Q>
fn borrow_mut(&mut self) -> &mut State<Q>
Source§impl<Q, A> BorrowMut<State<Q>> for Tail<Q, A>where
Q: RawState,
impl<Q, A> BorrowMut<State<Q>> for Tail<Q, A>where
Q: RawState,
Source§fn borrow_mut(&mut self) -> &mut State<Q>
fn borrow_mut(&mut self) -> &mut State<Q>
Source§impl<'a, _A, _B, _C> Div<&'a mut State<_B>> for State<_A>where
_A: Div<&'a mut _B, Output = _C>,
impl<'a, _A, _B, _C> Div<&'a mut State<_B>> for State<_A>where
_A: Div<&'a mut _B, Output = _C>,
Source§impl<'a, _A, _B, _C> Div<State<_B>> for &'a mut State<_A>where
&'a mut _A: Div<_B, Output = _C>,
impl<'a, _A, _B, _C> Div<State<_B>> for &'a mut State<_A>where
&'a mut _A: Div<_B, Output = _C>,
Source§impl<_A, _B> DivAssign<State<_B>> for State<_A>where
_A: DivAssign<_B>,
impl<_A, _B> DivAssign<State<_B>> for State<_A>where
_A: DivAssign<_B>,
Source§fn div_assign(&mut self, rhs: State<_B>)
fn div_assign(&mut self, rhs: State<_B>)
/= operation. Read moreSource§impl<'a, _A, _B, _C> Mul<&'a mut State<_B>> for State<_A>where
_A: Mul<&'a mut _B, Output = _C>,
impl<'a, _A, _B, _C> Mul<&'a mut State<_B>> for State<_A>where
_A: Mul<&'a mut _B, Output = _C>,
Source§impl<'a, _A, _B, _C> Mul<State<_B>> for &'a mut State<_A>where
&'a mut _A: Mul<_B, Output = _C>,
impl<'a, _A, _B, _C> Mul<State<_B>> for &'a mut State<_A>where
&'a mut _A: Mul<_B, Output = _C>,
Source§impl<_A, _B> MulAssign<State<_B>> for State<_A>where
_A: MulAssign<_B>,
impl<_A, _B> MulAssign<State<_B>> for State<_A>where
_A: MulAssign<_B>,
Source§fn mul_assign(&mut self, rhs: State<_B>)
fn mul_assign(&mut self, rhs: State<_B>)
*= operation. Read moreSource§impl<Q> Num for State<Q>where
Q: Num,
impl<Q> Num for State<Q>where
Q: Num,
type FromStrRadixErr = <Q as Num>::FromStrRadixErr
Source§impl<Q> Ord for State<Q>
impl<Q> Ord for State<Q>
Source§impl<'a, Q> PartialOrd<&'a Q> for State<Q>where
Q: PartialOrd,
impl<'a, Q> PartialOrd<&'a Q> for State<Q>where
Q: PartialOrd,
Source§impl<'a, Q> PartialOrd<&'a mut Q> for State<Q>where
Q: PartialOrd,
impl<'a, Q> PartialOrd<&'a mut Q> for State<Q>where
Q: PartialOrd,
Source§impl<Q> PartialOrd<Q> for State<Q>where
Q: PartialOrd,
impl<Q> PartialOrd<Q> for State<Q>where
Q: PartialOrd,
Source§impl<Q> PartialOrd for State<Q>where
Q: PartialOrd + ?Sized,
impl<Q> PartialOrd for State<Q>where
Q: PartialOrd + ?Sized,
Source§impl<'a, _A, _B, _C> Rem<&'a mut State<_B>> for State<_A>where
_A: Rem<&'a mut _B, Output = _C>,
impl<'a, _A, _B, _C> Rem<&'a mut State<_B>> for State<_A>where
_A: Rem<&'a mut _B, Output = _C>,
Source§impl<'a, _A, _B, _C> Rem<State<_B>> for &'a mut State<_A>where
&'a mut _A: Rem<_B, Output = _C>,
impl<'a, _A, _B, _C> Rem<State<_B>> for &'a mut State<_A>where
&'a mut _A: Rem<_B, Output = _C>,
Source§impl<_A, _B> RemAssign<State<_B>> for State<_A>where
_A: RemAssign<_B>,
impl<_A, _B> RemAssign<State<_B>> for State<_A>where
_A: RemAssign<_B>,
Source§fn rem_assign(&mut self, rhs: State<_B>)
fn rem_assign(&mut self, rhs: State<_B>)
%= operation. Read moreSource§impl<'a, _A, _B, _C> Shl<&'a mut State<_B>> for State<_A>where
_A: Shl<&'a mut _B, Output = _C>,
impl<'a, _A, _B, _C> Shl<&'a mut State<_B>> for State<_A>where
_A: Shl<&'a mut _B, Output = _C>,
Source§impl<'a, _A, _B, _C> Shl<State<_B>> for &'a mut State<_A>where
&'a mut _A: Shl<_B, Output = _C>,
impl<'a, _A, _B, _C> Shl<State<_B>> for &'a mut State<_A>where
&'a mut _A: Shl<_B, Output = _C>,
Source§impl<_A, _B> ShlAssign<State<_B>> for State<_A>where
_A: ShlAssign<_B>,
impl<_A, _B> ShlAssign<State<_B>> for State<_A>where
_A: ShlAssign<_B>,
Source§fn shl_assign(&mut self, rhs: State<_B>)
fn shl_assign(&mut self, rhs: State<_B>)
<<= operation. Read moreSource§impl<'a, _A, _B, _C> Shr<&'a mut State<_B>> for State<_A>where
_A: Shr<&'a mut _B, Output = _C>,
impl<'a, _A, _B, _C> Shr<&'a mut State<_B>> for State<_A>where
_A: Shr<&'a mut _B, Output = _C>,
Source§impl<'a, _A, _B, _C> Shr<State<_B>> for &'a mut State<_A>where
&'a mut _A: Shr<_B, Output = _C>,
impl<'a, _A, _B, _C> Shr<State<_B>> for &'a mut State<_A>where
&'a mut _A: Shr<_B, Output = _C>,
Source§impl<_A, _B> ShrAssign<State<_B>> for State<_A>where
_A: ShrAssign<_B>,
impl<_A, _B> ShrAssign<State<_B>> for State<_A>where
_A: ShrAssign<_B>,
Source§fn shr_assign(&mut self, rhs: State<_B>)
fn shr_assign(&mut self, rhs: State<_B>)
>>= operation. Read moreSource§impl<'a, _A, _B, _C> Sub<&'a mut State<_B>> for State<_A>where
_A: Sub<&'a mut _B, Output = _C>,
impl<'a, _A, _B, _C> Sub<&'a mut State<_B>> for State<_A>where
_A: Sub<&'a mut _B, Output = _C>,
Source§impl<'a, _A, _B, _C> Sub<State<_B>> for &'a mut State<_A>where
&'a mut _A: Sub<_B, Output = _C>,
impl<'a, _A, _B, _C> Sub<State<_B>> for &'a mut State<_A>where
&'a mut _A: Sub<_B, Output = _C>,
Source§impl<_A, _B> SubAssign<State<_B>> for State<_A>where
_A: SubAssign<_B>,
impl<_A, _B> SubAssign<State<_B>> for State<_A>where
_A: SubAssign<_B>,
Source§fn sub_assign(&mut self, rhs: State<_B>)
fn sub_assign(&mut self, rhs: State<_B>)
-= operation. Read more