Struct bones_asset::bones_utils::prelude::rng::Rng
pub struct Rng(/* private fields */);
Expand description
A Random Number generator, powered by the WyRand
algorithm.
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§
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<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.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§impl<T> RawDrop for T
impl<T> RawDrop 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.