#[repr(transparent)]pub struct State<Q: ?Sized = bool>(pub Q);
Expand description
State is a generalized state implementation, representing the state of a system or object.
Tuple Fields§
§0: Q
Implementations§
Source§impl<Q> State<*mut Q>where
Q: RawState,
impl<Q> State<*mut Q>where
Q: RawState,
Sourcepub fn from_mut_ptr(ptr: *mut Q) -> Self
pub fn from_mut_ptr(ptr: *mut Q) -> Self
Creates a new instance of state with a mutable raw pointer to the inner value.
Source§impl<Q> State<MaybeUninit<Q>>where
Q: RawState,
impl<Q> State<MaybeUninit<Q>>where
Q: RawState,
Sourcepub const fn uninit() -> Self
pub const fn uninit() -> Self
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>
Converts the state into a new instance of State with an initialized state.
Source§impl State<Box<dyn Any>>
impl State<Box<dyn Any>>
Sourcepub fn downcast<Q>(self) -> Result<State<Box<Q>>, Error>where
Q: Any,
pub fn downcast<Q>(self) -> Result<State<Box<Q>>, Error>where
Q: Any,
Attempts to downcast the state to a concrete type Q
; returns an error if the state
is not of type Q
.
Source§impl<Q> State<Option<Q>>where
Q: RawState,
impl<Q> State<Option<Q>>where
Q: RawState,
Sourcepub fn none() -> Self
pub fn none() -> Self
Creates a new instance of state whose inner state is Option::None.
Sourcepub fn some(value: Q) -> Self
pub fn some(value: Q) -> Self
Creates a new instance of state whose inner state is Option::Some.
Source§impl<Q> State<Q>
impl<Q> State<Q>
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 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 fn reset(&mut self) -> &mut Selfwhere
Q: Default,
pub fn reset(&mut self) -> &mut Selfwhere
Q: Default,
Clears the state, setting it to its default value.
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>>
pub fn as_halt(&self) -> State<Halt<&Q>>
returns a halted state with an immutable reference to the state.
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
Wraps the inner value of the state with an [Arc
] and returns a new instance of State
returns a shared reference to the state.
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 fn get_inner_type_id(&self) -> TypeIdwhere
Q: 'static,
pub fn get_inner_type_id(&self) -> TypeIdwhere
Q: 'static,
returns the type id
of the generic inner type, Q
.
Source§impl<Q> State<Q>
impl<Q> State<Q>
pub fn into_inner(self) -> Q
value
instead, as it is more idiomatic and clearer.pub fn to_ref(&self) -> State<&Q>
view
instead, as it is more idiomatic and clearer.pub fn to_mut(&mut self) -> State<&mut Q>
view_mut
instead, as it is more idiomatic and clearer.Trait Implementations§
Source§impl<A, B> AddAssign<B> for State<A>
impl<A, B> AddAssign<B> for State<A>
Source§fn add_assign(&mut self, rhs: B)
fn add_assign(&mut self, rhs: B)
+=
operation. Read moreSource§impl<A, B> BitAndAssign<B> for State<A>
impl<A, B> BitAndAssign<B> for State<A>
Source§fn bitand_assign(&mut self, rhs: B)
fn bitand_assign(&mut self, rhs: B)
&=
operation. Read moreSource§impl<A, B> BitOrAssign<B> for State<A>
impl<A, B> BitOrAssign<B> for State<A>
Source§fn bitor_assign(&mut self, rhs: B)
fn bitor_assign(&mut self, rhs: B)
|=
operation. Read moreSource§impl<A, B> BitXorAssign<B> for State<A>
impl<A, B> BitXorAssign<B> for State<A>
Source§fn bitxor_assign(&mut self, rhs: B)
fn bitxor_assign(&mut self, rhs: 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<'de, Q> Deserialize<'de> for State<Q>where
Q: Deserialize<'de> + ?Sized,
impl<'de, Q> Deserialize<'de> for State<Q>where
Q: Deserialize<'de> + ?Sized,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl<A, B> DivAssign<B> for State<A>
impl<A, B> DivAssign<B> for State<A>
Source§fn div_assign(&mut self, rhs: B)
fn div_assign(&mut self, rhs: B)
/=
operation. Read moreSource§impl<A, B> MulAssign<B> for State<A>
impl<A, B> MulAssign<B> for State<A>
Source§fn mul_assign(&mut self, rhs: B)
fn mul_assign(&mut self, rhs: B)
*=
operation. Read moreSource§impl<Q> Num for State<Q>
impl<Q> Num for State<Q>
type FromStrRadixErr = <Q as Num>::FromStrRadixErr
Source§fn from_str_radix(str: &str, radix: u32) -> Result<Self, Self::FromStrRadixErr>
fn from_str_radix(str: &str, radix: u32) -> Result<Self, Self::FromStrRadixErr>
2..=36
). Read moreSource§impl<Q: Ord + ?Sized> Ord for State<Q>
impl<Q: Ord + ?Sized> Ord for State<Q>
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 + ?Sized> PartialOrd for State<Q>
impl<Q: PartialOrd + ?Sized> PartialOrd for State<Q>
Source§impl<A, B> RemAssign<B> for State<A>
impl<A, B> RemAssign<B> for State<A>
Source§fn rem_assign(&mut self, rhs: B)
fn rem_assign(&mut self, rhs: B)
%=
operation. Read moreSource§impl<A, B> ShlAssign<B> for State<A>
impl<A, B> ShlAssign<B> for State<A>
Source§fn shl_assign(&mut self, rhs: B)
fn shl_assign(&mut self, rhs: B)
<<=
operation. Read moreSource§impl<A, B> ShrAssign<B> for State<A>
impl<A, B> ShrAssign<B> for State<A>
Source§fn shr_assign(&mut self, rhs: B)
fn shr_assign(&mut self, rhs: B)
>>=
operation. Read moreSource§impl<A, B> SubAssign<B> for State<A>
impl<A, B> SubAssign<B> for State<A>
Source§fn sub_assign(&mut self, rhs: B)
fn sub_assign(&mut self, rhs: B)
-=
operation. Read moreimpl<Q: Copy + ?Sized> Copy for State<Q>
impl<Q: Eq + ?Sized> Eq for State<Q>
impl<Q> Send for State<Q>where
Q: Send,
impl<Q: ?Sized> StructuralPartialEq for State<Q>
impl<Q> Sync for State<Q>where
Q: Sync,
Auto Trait Implementations§
impl<Q> Freeze for State<Q>
impl<Q> RefUnwindSafe for State<Q>where
Q: RefUnwindSafe + ?Sized,
impl<Q> Unpin for State<Q>
impl<Q> UnwindSafe for State<Q>where
Q: UnwindSafe + ?Sized,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<K, S> Identity<K> for Swhere
S: Borrow<K>,
K: Identifier,
impl<K, S> Identity<K> for Swhere
S: Borrow<K>,
K: Identifier,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<R> Rng for R
impl<R> Rng for R
Source§fn random<T>(&mut self) -> Twhere
StandardUniform: Distribution<T>,
fn random<T>(&mut self) -> Twhere
StandardUniform: Distribution<T>,
StandardUniform
distribution. Read moreSource§fn random_iter<T>(self) -> Iter<StandardUniform, Self, T>
fn random_iter<T>(self) -> Iter<StandardUniform, Self, T>
Source§fn random_range<T, R>(&mut self, range: R) -> Twhere
T: SampleUniform,
R: SampleRange<T>,
fn random_range<T, R>(&mut self, range: R) -> Twhere
T: SampleUniform,
R: SampleRange<T>,
Source§fn random_bool(&mut self, p: f64) -> bool
fn random_bool(&mut self, p: f64) -> bool
p
of being true. Read moreSource§fn random_ratio(&mut self, numerator: u32, denominator: u32) -> bool
fn random_ratio(&mut self, numerator: u32, denominator: u32) -> bool
numerator/denominator
of being
true. Read moreSource§fn sample<T, D>(&mut self, distr: D) -> Twhere
D: Distribution<T>,
fn sample<T, D>(&mut self, distr: D) -> Twhere
D: Distribution<T>,
Source§fn sample_iter<T, D>(self, distr: D) -> Iter<D, Self, T>where
D: Distribution<T>,
Self: Sized,
fn sample_iter<T, D>(self, distr: D) -> Iter<D, Self, T>where
D: Distribution<T>,
Self: Sized,
Source§fn gen<T>(&mut self) -> Twhere
StandardUniform: Distribution<T>,
fn gen<T>(&mut self) -> Twhere
StandardUniform: Distribution<T>,
random
to avoid conflict with the new gen
keyword in Rust 2024.Rng::random
.Source§fn gen_range<T, R>(&mut self, range: R) -> Twhere
T: SampleUniform,
R: SampleRange<T>,
fn gen_range<T, R>(&mut self, range: R) -> Twhere
T: SampleUniform,
R: SampleRange<T>,
random_range
Rng::random_range
.Source§impl<R> TryRngCore for R
impl<R> TryRngCore for R
Source§type Error = Infallible
type Error = Infallible
Source§fn try_next_u32(&mut self) -> Result<u32, <R as TryRngCore>::Error>
fn try_next_u32(&mut self) -> Result<u32, <R as TryRngCore>::Error>
u32
.Source§fn try_next_u64(&mut self) -> Result<u64, <R as TryRngCore>::Error>
fn try_next_u64(&mut self) -> Result<u64, <R as TryRngCore>::Error>
u64
.Source§fn try_fill_bytes(
&mut self,
dst: &mut [u8],
) -> Result<(), <R as TryRngCore>::Error>
fn try_fill_bytes( &mut self, dst: &mut [u8], ) -> Result<(), <R as TryRngCore>::Error>
dest
entirely with random data.Source§fn unwrap_mut(&mut self) -> UnwrapMut<'_, Self>
fn unwrap_mut(&mut self) -> UnwrapMut<'_, Self>
UnwrapMut
wrapper.Source§fn read_adapter(&mut self) -> RngReadAdapter<'_, Self>where
Self: Sized,
fn read_adapter(&mut self) -> RngReadAdapter<'_, Self>where
Self: Sized,
RngCore
to a RngReadAdapter
.