pub struct Lgc16(/* private fields */);
Available on crate feature
rand
only.Expand description
๐ฒ A 16-bit LCG PRNG.
Based on original code from Ken Musgrave, 1985, in Graphics Gems II.
Implementationsยง
Sourceยงimpl Lgc16
impl Lgc16
Sourcepub const fn inner_state(self) -> u16
pub const fn inner_state(self) -> u16
Returns the PRNGโs inner state as a raw snapshot.
Sourcepub const fn from_state(state: u16) -> Self
pub const fn from_state(state: u16) -> Self
Restores the PRNG from the given state.
Sourcepub const fn current_u16(&self) -> u16
pub const fn current_u16(&self) -> u16
Returns the current seed value.
Sourcepub const fn peek_next_state(&self) -> Self
pub const fn peek_next_state(&self) -> Self
Returns a copy of the next state of the generator.
Sourcepub const fn own_next_u16(self) -> Own<Self, u16>
pub const fn own_next_u16(self) -> Own<Self, u16>
Returns both the next state and the u16
value.
Trait Implementationsยง
Sourceยงimpl ConstDefault for Lgc16
Creates a new PRNG initialized with the default fixed seed.
impl ConstDefault for Lgc16
Creates a new PRNG initialized with the default fixed seed.
Sourceยงimpl SeedableRng for Lgc16
Available on crate features dep_rand_core
and join
only.
impl SeedableRng for Lgc16
Available on crate features
dep_rand_core
and join
only.Sourceยงfn from_seed(seed: Self::Seed) -> Self
fn from_seed(seed: Self::Seed) -> Self
When seeded with zero this implementation uses the default seed value as the cold path.
Sourceยงtype Seed = [u8; 2]
type Seed = [u8; 2]
Seed type, which is restricted to types mutably-dereferenceable as
u8
arrays (we recommend [u8; N]
for some N
). Read moreSourceยงfn seed_from_u64(state: u64) -> Self
fn seed_from_u64(state: u64) -> Self
Create a new PRNG using a
u64
seed. Read moreSourceยงfn from_rng(rng: &mut impl RngCore) -> Self
fn from_rng(rng: &mut impl RngCore) -> Self
Create a new PRNG seeded from an infallible
Rng
. Read moreSourceยงfn try_from_rng<R>(rng: &mut R) -> Result<Self, <R as TryRngCore>::Error> โwhere
R: TryRngCore,
fn try_from_rng<R>(rng: &mut R) -> Result<Self, <R as TryRngCore>::Error> โwhere
R: TryRngCore,
Create a new PRNG seeded from a potentially fallible
Rng
. Read moreimpl Eq for Lgc16
impl StructuralPartialEq for Lgc16
Auto Trait Implementationsยง
impl Freeze for Lgc16
impl RefUnwindSafe for Lgc16
impl Send for Lgc16
impl Sync for Lgc16
impl Unpin for Lgc16
impl UnwindSafe for Lgc16
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> ByteSized for T
impl<T> ByteSized for T
Sourceยงconst BYTE_ALIGN: usize = _
const BYTE_ALIGN: usize = _
The alignment of this type in bytes.
Sourceยงfn byte_align(&self) -> usize
fn byte_align(&self) -> usize
Returns the alignment of this type in bytes.
Sourceยงfn ptr_size_ratio(&self) -> [usize; 2]
fn ptr_size_ratio(&self) -> [usize; 2]
Sourceยงimpl<T, R> Chain<R> for Twhere
T: ?Sized,
impl<T, R> Chain<R> for Twhere
T: ?Sized,
Sourceยงimpl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
ยงimpl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
ยงfn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.Sourceยงimpl<T> ExtAny for T
impl<T> ExtAny for T
Sourceยงfn type_hash_with<H: Hasher>(&self, hasher: H) -> u64
fn type_hash_with<H: Hasher>(&self, hasher: H) -> u64
Returns a deterministic hash of the
TypeId
of Self
using a custom hasher.Sourceยงfn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
fn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
Sourceยงimpl<T> ExtMem for Twhere
T: ?Sized,
impl<T> ExtMem for Twhere
T: ?Sized,
Sourceยงconst NEEDS_DROP: bool = _
const NEEDS_DROP: bool = _
Know whether dropping values of this type matters, in compile-time.
Sourceยงfn mem_align_of<T>() -> usize
fn mem_align_of<T>() -> usize
Returns the minimum alignment of the type in bytes. Read more
Sourceยงfn mem_align_of_val(&self) -> usize
fn mem_align_of_val(&self) -> usize
Returns the alignment of the pointed-to value in bytes. Read more
Sourceยงfn mem_size_of<T>() -> usize
fn mem_size_of<T>() -> usize
Returns the size of a type in bytes. Read more
Sourceยงfn mem_size_of_val(&self) -> usize
fn mem_size_of_val(&self) -> usize
Returns the size of the pointed-to value in bytes. Read more
Sourceยงfn mem_needs_drop(&self) -> bool
fn mem_needs_drop(&self) -> bool
Returns
true
if dropping values of this type matters. Read moreSourceยงfn mem_forget(self)where
Self: Sized,
fn mem_forget(self)where
Self: Sized,
Forgets about
self
without running its destructor. Read moreSourceยงfn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
fn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
Sourceยงunsafe fn mem_zeroed<T>() -> T
unsafe fn mem_zeroed<T>() -> T
Available on crate feature
unsafe_layout
only.Returns the value of type
T
represented by the all-zero byte-pattern. Read moreSourceยงunsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst
unsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst
Available on crate feature
unsafe_layout
only.Returns the value of type
T
represented by the all-zero byte-pattern. Read moreSourceยงfn mem_as_bytes(&self) -> &[u8] โ
fn mem_as_bytes(&self) -> &[u8] โ
Available on crate feature
unsafe_slice
only.ยงimpl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Sourceยงimpl<T> Hook for T
impl<T> Hook for T
Sourceยงimpl<T> IntoEither for T
impl<T> IntoEither for T
Sourceยงfn into_either(self, into_left: bool) -> Either<Self, Self> โ
fn into_either(self, into_left: bool) -> Either<Self, Self> โ
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSourceยงfn into_either_with<F>(self, into_left: F) -> Either<Self, Self> โ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> โ
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreยงimpl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
ยงimpl<T> Pointable for T
impl<T> Pointable for T
ยงimpl<T, U> ToSample<U> for Twhere
U: FromSample<T>,
impl<T, U> ToSample<U> for Twhere
U: FromSample<T>,
fn to_sample_(self) -> U
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_err(self) -> UnwrapErr<Self>where
Self: Sized,
fn unwrap_err(self) -> UnwrapErr<Self>where
Self: Sized,
Wrap RNG with the
UnwrapErr
wrapper.Sourceยงfn unwrap_mut(&mut self) -> UnwrapMut<'_, Self>
fn unwrap_mut(&mut self) -> UnwrapMut<'_, Self>
Wrap RNG with the
UnwrapMut
wrapper.