#[repr(transparent)]pub struct State<Q = usize>(pub Q);Tuple Fields§
§0: QImplementations§
Source§impl<T> State<MaybeUninit<T>>
impl<T> State<MaybeUninit<T>>
Sourcepub fn unit() -> State<MaybeUninit<T>>
pub fn unit() -> State<MaybeUninit<T>>
returns a new instance containing a reference to the inner value
Source§impl<Q> State<Q>
generic implementation of the State type available for all types Q
impl<Q> State<Q>
generic implementation of the State type available for all types Q
Sourcepub fn from_value(id: Q) -> Self
pub fn from_value(id: Q) -> Self
create a new identifier from the given value
pub fn random() -> Selfwhere
StandardUniform: Distribution<Q>,
Sourcepub fn into_inner(self) -> Q
pub fn into_inner(self) -> Q
consumes the current instance to return the inner value
Sourcepub fn replace(&mut self, id: Q) -> Q
pub fn replace(&mut self, id: Q) -> Q
use the replace method to update and return the inner value
Sourcepub fn set(&mut self, id: Q) -> &mut Self
pub fn set(&mut self, id: Q) -> &mut Self
mutate the inner value and return a mutable reference to the wrapper for chaining
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
pub fn to_owned(self) -> State<Q>where
Q: Clone,
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>)
Performs the
+= 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>)
Performs the
&= 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>)
Performs the
|= 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>)
Performs the
^= 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
Mutably borrows from an owned value. Read more
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>,
Deserialize this value from the given Serde deserializer. Read more
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>)
Performs the
/= 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>)
Performs the
*= operation. Read moreSource§impl<Q: Ord> Ord for State<Q>
impl<Q: Ord> Ord for State<Q>
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>)
Performs the
%= 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>)
Performs the
<<= 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>)
Performs the
>>= 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>)
Performs the
-= 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
Mutably borrows from an owned value. Read more
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>,
Return a random value via the
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>,
Generate a random value in the given range. Read more
Source§fn random_bool(&mut self, p: f64) -> bool
fn random_bool(&mut self, p: f64) -> bool
Return a bool with a probability
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
Return a bool with a probability of
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>,
Sample a new value, using the given distribution. Read more
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,
Create an iterator that generates values using the given distribution. Read more
Source§fn gen<T>(&mut self) -> Twhere
StandardUniform: Distribution<T>,
fn gen<T>(&mut self) -> Twhere
StandardUniform: Distribution<T>,
👎Deprecated since 0.9.0: Renamed to
random to avoid conflict with the new gen keyword in Rust 2024.Alias for
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>,
👎Deprecated since 0.9.0: Renamed to
random_rangeAlias for
Rng::random_range.Source§impl<R> TryRngCore for R
impl<R> TryRngCore for R
Source§type Error = Infallible
type Error = Infallible
The type returned in the event of a RNG error.
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>
Return the next random
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>
Return the next random
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>
Fill
dest entirely with random data.Source§fn unwrap_mut(&mut self) -> UnwrapMut<'_, Self>
fn unwrap_mut(&mut self) -> UnwrapMut<'_, Self>
Wrap RNG with the
UnwrapMut wrapper.Source§fn read_adapter(&mut self) -> RngReadAdapter<'_, Self>where
Self: Sized,
fn read_adapter(&mut self) -> RngReadAdapter<'_, Self>where
Self: Sized,
Convert an
RngCore to a RngReadAdapter.