#[repr(transparent)]pub struct State<Q = usize>(pub Q);
Tuple Fields§
§0: Q
Implementations§
Source§impl<Q> State<Q>where
Q: RawState,
generic implementation of the State
type available for all types Q
impl<Q> State<Q>where
Q: RawState,
generic implementation of the State
type available for all types Q
Sourcepub fn new_with<F>(f: F) -> Selfwhere
F: FnOnce() -> Q,
pub fn new_with<F>(f: F) -> Selfwhere
F: FnOnce() -> Q,
returns a new instance of State
using the output of the given function F
Sourcepub fn default() -> Selfwhere
Q: Default,
pub fn default() -> Selfwhere
Q: Default,
returns a new instance of State
using the logical default for the type Q
Sourcepub fn random() -> Selfwhere
StandardUniform: Distribution<Q>,
pub fn random() -> Selfwhere
StandardUniform: Distribution<Q>,
generate a new instance of the state with a random value
pub fn random_with<R, Dist>(rng: &mut R, distr: Dist) -> Selfwhere
Dist: Distribution<Q>,
R: RngCore,
Sourcepub const fn replace(&mut self, state: Q) -> Q
pub const fn replace(&mut self, state: Q) -> Q
replace
the inner state with the given value and return the
previous
Sourcepub fn set(&mut self, state: Q) -> &mut Self
pub fn set(&mut self, state: Q) -> &mut Self
mutate the inner value and return a mutable reference to the wrapper for chaining
Sourcepub const fn swap(&mut self, state: &mut State<Q>)
pub const fn swap(&mut self, state: &mut State<Q>)
swap
the inner value with that of another state instance of the
same type Q
Sourcepub fn take(&mut self) -> Qwhere
Q: Default,
pub fn take(&mut self) -> Qwhere
Q: Default,
takes the inner value and replaces it with the default value
Sourcepub fn with<U>(self, id: U) -> State<U>
pub fn with<U>(self, id: U) -> State<U>
consumes the current instance to replace it with another.
Sourcepub fn map<U, F>(self, f: F) -> State<U>where
F: FnOnce(Q) -> U,
pub fn map<U, F>(self, f: F) -> State<U>where
F: FnOnce(Q) -> U,
apply a function onto the inner value and return a new instance with the result
Sourcepub fn map_inplace<F>(&mut self, f: F) -> &mut Self
pub fn map_inplace<F>(&mut self, f: F) -> &mut Self
updates the inner value using the given function and returns a mutable reference to the current instance for chaining
Source§impl<Q> State<Q>where
Q: RawState,
impl<Q> State<Q>where
Q: RawState,
pub fn into_inner(self) -> Q
value
instead, this will be removed in the next major releaseSource§impl<Q> State<MaybeUninit<Q>>where
Q: RawState,
impl<Q> State<MaybeUninit<Q>>where
Q: RawState,
Sourcepub fn uninit() -> State<MaybeUninit<Q>>
pub fn uninit() -> State<MaybeUninit<Q>>
returns a new state with an uninitialized
inner state
Sourcepub fn init(value: Q) -> State<MaybeUninit<Q>>
pub fn init(value: Q) -> State<MaybeUninit<Q>>
returns a new state with an initialized
inner state
Trait Implementations§
Source§impl<A, B> AddAssign<State<B>> for &mut State<A>where
A: AddAssign<B>,
impl<A, B> AddAssign<State<B>> for &mut 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, B> BitAndAssign<State<B>> for &mut State<A>where
A: BitAndAssign<B>,
impl<A, B> BitAndAssign<State<B>> for &mut 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, B> BitOrAssign<State<B>> for &mut State<A>where
A: BitOrAssign<B>,
impl<A, B> BitOrAssign<State<B>> for &mut 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, B> BitXorAssign<State<B>> for &mut State<A>where
A: BitXorAssign<B>,
impl<A, B> BitXorAssign<State<B>> for &mut 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>where
Q: RawState,
impl<Q> BorrowMut<Q> for State<Q>where
Q: RawState,
Source§fn borrow_mut(&mut self) -> &mut Q
fn borrow_mut(&mut self) -> &mut Q
Source§impl<'de, Q> Deserialize<'de> for State<Q>
impl<'de, Q> Deserialize<'de> for State<Q>
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<State<B>> for &mut State<A>where
A: DivAssign<B>,
impl<A, B> DivAssign<State<B>> for &mut 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, B> MulAssign<State<B>> for &mut State<A>where
A: MulAssign<B>,
impl<A, B> MulAssign<State<B>> for &mut 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>
impl<Q> Num for State<Q>
type FromStrRadixErr = <Q as Num>::FromStrRadixErr
Source§fn from_str_radix(s: &str, radix: u32) -> Result<Self, Self::FromStrRadixErr>
fn from_str_radix(s: &str, radix: u32) -> Result<Self, Self::FromStrRadixErr>
2..=36
). Read moreSource§impl<Q: Ord> Ord for State<Q>
impl<Q: Ord> Ord for State<Q>
Source§impl<Q> PartialOrd<Q> for State<Q>where
Q: RawState + PartialOrd,
impl<Q> PartialOrd<Q> for State<Q>where
Q: RawState + PartialOrd,
Source§impl<Q: PartialOrd> PartialOrd for State<Q>
impl<Q: PartialOrd> PartialOrd for State<Q>
Source§impl<A, B> RemAssign<State<B>> for &mut State<A>where
A: RemAssign<B>,
impl<A, B> RemAssign<State<B>> for &mut 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, B> ShlAssign<State<B>> for &mut State<A>where
A: ShlAssign<B>,
impl<A, B> ShlAssign<State<B>> for &mut 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, B> ShrAssign<State<B>> for &mut State<A>where
A: ShrAssign<B>,
impl<A, B> ShrAssign<State<B>> for &mut 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, B> SubAssign<State<B>> for &mut State<A>where
A: SubAssign<B>,
impl<A, B> SubAssign<State<B>> for &mut 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 moreimpl<Q: Copy> Copy for State<Q>
impl<Q: Eq> Eq for State<Q>
impl<Q> StructuralPartialEq for State<Q>
Auto Trait Implementations§
impl<Q> Freeze for State<Q>where
Q: Freeze,
impl<Q> RefUnwindSafe for State<Q>where
Q: RefUnwindSafe,
impl<Q> Send for State<Q>where
Q: Send,
impl<Q> Sync for State<Q>where
Q: Sync,
impl<Q> Unpin for State<Q>where
Q: Unpin,
impl<Q> UnwindSafe for State<Q>where
Q: UnwindSafe,
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<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
.