#[repr(transparent)]pub struct Rng(WyRand);
Expand description
A Random Number generator, powered by the WyRand
algorithm.
Tuple Fields§
§0: WyRand
Implementations§
Trait Implementations§
§impl ForkableCore for Rng
impl ForkableCore for Rng
§impl GenCore for Rng
impl GenCore for Rng
§const GEN_KIND: TurboKind = TurboKind::FAST
const GEN_KIND: TurboKind = TurboKind::FAST
Determines the kind of PRNG.
TurboKind::FAST
RNGs are meant to be very
quick, non-cryptographic PRNGs, while TurboKind::SLOW
are slower,
more expensive PRNGs, usually CSPRNGs but not always. Setting this constant
allows for certain algorithms to be toggled for tuning performance of certain
methods.§impl SeededCore for Rng
impl SeededCore for Rng
§fn with_seed(seed: <Rng as SeededCore>::Seed) -> Rng
fn with_seed(seed: <Rng as SeededCore>::Seed) -> Rng
Creates a new
SeededCore
with a specific seed value.§fn reseed(&self, seed: <Rng as SeededCore>::Seed)
fn reseed(&self, seed: <Rng as SeededCore>::Seed)
Reseeds the
SeededCore
with a new seed/state.§impl TurboCore for Rng
impl TurboCore for Rng
§fn fill_bytes(&self, buffer: &mut [u8])
fn fill_bytes(&self, buffer: &mut [u8])
Fills a mutable buffer with random bytes. Read more
impl Eq for Rng
impl StructuralPartialEq for Rng
Auto Trait Implementations§
impl !Freeze for Rng
impl !RefUnwindSafe for Rng
impl Send for Rng
impl !Sync for Rng
impl Unpin for Rng
impl UnwindSafe for Rng
Blanket Implementations§
§impl<T, U> AsBindGroupShaderType<U> for T
impl<T, U> AsBindGroupShaderType<U> for T
§fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U
Return the
T
[ShaderType
] for self
. When used in [AsBindGroup
]
derives, it is safe to assume that all images in self
exist.§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)§impl<T> Conv for T
impl<T> Conv for T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DynEq for T
impl<T> DynEq for T
§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
Checks if this value is equivalent to the given key. Read more
§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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
fn equivalent(&self, key: &K) -> bool
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
Causes
self
to use its Binary
implementation when Debug
-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
Causes
self
to use its Display
implementation when
Debug
-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
Causes
self
to use its LowerExp
implementation when
Debug
-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
Causes
self
to use its LowerHex
implementation when
Debug
-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
Causes
self
to use its Octal
implementation when Debug
-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
Causes
self
to use its Pointer
implementation when
Debug
-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
Causes
self
to use its UpperExp
implementation when
Debug
-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
Causes
self
to use its UpperHex
implementation when
Debug
-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
Formats each item in a sequence. Read more
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Creates
Self
using data from the given [World]§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
§fn from_world(_world: &World) -> T
fn from_world(_world: &World) -> T
Creates
Self
using data from the given World
.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Pipes by value. This is generally the method you want to use. Read more
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
Borrows
self
and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
Mutably borrows
self
and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
Borrows
self
, then passes self.as_ref()
into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
Mutably borrows
self
, then passes self.as_mut()
into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
Borrows
self
, then passes self.deref()
into the pipe function.§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> RawDefault for Twhere
T: Default,
impl<T> RawDefault for Twhere
T: Default,
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Immutable access to the
Borrow<B>
of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
Mutable access to the
BorrowMut<B>
of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
Immutable access to the
AsRef<R>
view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
Mutable access to the
AsMut<R>
view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Immutable access to the
Deref::Target
of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Mutable access to the
Deref::Target
of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
Calls
.tap()
only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
Calls
.tap_mut()
only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
Calls
.tap_borrow()
only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
Calls
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
Calls
.tap_ref()
only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
Calls
.tap_ref_mut()
only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
Calls
.tap_deref()
only in debug builds, and is erased in release
builds.§impl<Q> ToOwnedEquivalent<<Q as ToOwned>::Owned> for Q
impl<Q> ToOwnedEquivalent<<Q as ToOwned>::Owned> for Q
fn to_owned_equivalent(&self) -> <Q as ToOwned>::Owned
§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
§impl<T> TryConv for T
impl<T> TryConv for T
§impl<T> TurboRand for T
impl<T> TurboRand for T
§fn u128(&self, bounds: impl RangeBounds<u128>) -> u128
fn u128(&self, bounds: impl RangeBounds<u128>) -> u128
Returns a random
u128
within a given range bound. Read more§fn i128(&self, bounds: impl RangeBounds<i128>) -> i128
fn i128(&self, bounds: impl RangeBounds<i128>) -> i128
Returns a random
i128
within a given range bound. Read more§fn usize(&self, bounds: impl RangeBounds<usize>) -> usize
fn usize(&self, bounds: impl RangeBounds<usize>) -> usize
Returns a random
usize
within a given range bound. Read more§fn isize(&self, bounds: impl RangeBounds<isize>) -> isize
fn isize(&self, bounds: impl RangeBounds<isize>) -> isize
Returns a random
isize
within a given range bound. Read more§fn f32_normalized(&self) -> f32
fn f32_normalized(&self) -> f32
Returns a random
f32
value between -1.0
and 1.0
.§fn f64_normalized(&self) -> f64
fn f64_normalized(&self) -> f64
Returns a random
f32
value between -1.0
and 1.0
.§fn index(&self, bound: impl RangeBounds<usize>) -> usize
fn index(&self, bound: impl RangeBounds<usize>) -> usize
Returns a
usize
value for stable indexing across different
word size platforms.§fn chance(&self, rate: f64) -> bool
fn chance(&self, rate: f64) -> bool
Returns a boolean value based on a rate.
rate
represents
the chance to return a true
value, with 0.0
being no
chance and 1.0
will always return true. Read more§fn sample<'a, T>(&self, list: &'a [T]) -> Option<&'a T>
fn sample<'a, T>(&self, list: &'a [T]) -> Option<&'a T>
Samples a random item from a slice of values. Read more
§fn sample_iter<T>(&self, list: T) -> Option<<T as Iterator>::Item>where
T: Iterator,
fn sample_iter<T>(&self, list: T) -> Option<<T as Iterator>::Item>where
T: Iterator,
Samples a random item from an iterator of values.
O(1)
if the
iterator provides an accurate Iterator::size_hint
to allow
for optimisations to kick in, else O(n)
where n
is the size
of the iterator. Read more§fn sample_mut<'a, T>(&self, list: &'a mut [T]) -> Option<&'a mut T>
fn sample_mut<'a, T>(&self, list: &'a mut [T]) -> Option<&'a mut T>
Samples a random
&mut
item from a slice of values. Read more§fn sample_multiple<'a, T>(&self, list: &'a [T], amount: usize) -> Vec<&'a T>
fn sample_multiple<'a, T>(&self, list: &'a [T], amount: usize) -> Vec<&'a T>
Samples multiple unique items from a slice of values. Read more
§fn sample_multiple_mut<'a, T>(
&self,
list: &'a mut [T],
amount: usize,
) -> Vec<&'a mut T>
fn sample_multiple_mut<'a, T>( &self, list: &'a mut [T], amount: usize, ) -> Vec<&'a mut T>
Samples multiple unique items from a mutable slice of values. Read more
§fn sample_multiple_iter<T>(
&self,
list: T,
amount: usize,
) -> Vec<<T as Iterator>::Item>where
T: Iterator,
fn sample_multiple_iter<T>(
&self,
list: T,
amount: usize,
) -> Vec<<T as Iterator>::Item>where
T: Iterator,
Samples multiple unique items from an iterator of values. Read more
§fn weighted_sample<'a, T, F>(
&self,
list: &'a [T],
weight_sampler: F,
) -> Option<&'a T>
fn weighted_sample<'a, T, F>( &self, list: &'a [T], weight_sampler: F, ) -> Option<&'a T>
Stochastic Acceptance implementation of Roulette Wheel
weighted selection. Uses a closure to return a
rate
value for each randomly sampled item
to decide whether to return it or not. The returned f64
value must be between 0.0
and 1.0
. Read more§fn weighted_sample_mut<'a, T, F>(
&self,
list: &'a mut [T],
weight_sampler: F,
) -> Option<&'a mut T>
fn weighted_sample_mut<'a, T, F>( &self, list: &'a mut [T], weight_sampler: F, ) -> Option<&'a mut T>
Stochastic Acceptance implementation of Roulette Wheel
weighted selection. Uses a closure to return a
rate
value for each randomly sampled item
to decide whether to return it or not. The returned f64
value must be between 0.0
and 1.0
. Read more§fn partial_shuffle<'a, T>(
&self,
slice: &'a mut [T],
amount: usize,
) -> (&'a mut [T], &'a mut [T])
fn partial_shuffle<'a, T>( &self, slice: &'a mut [T], amount: usize, ) -> (&'a mut [T], &'a mut [T])
Partially shuffles a slice by a given amount and returns the shuffled part
and non-shuffled part. Read more
§fn alphabetic(&self) -> char
fn alphabetic(&self) -> char
Generates a random
char
in ranges a-z and A-Z.§fn alphanumeric(&self) -> char
fn alphanumeric(&self) -> char
Generates a random
char
in ranges a-z, A-Z and 0-9.