Struct bones_framework::lib::prelude::bones_schema::prelude::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 StructuralEq for Rng
impl StructuralPartialEq for Rng
Auto Trait Implementations§
impl !RefUnwindSafe for Rng
impl Send for Rng
impl !Sync for Rng
impl Unpin for Rng
impl UnwindSafe for Rng
Blanket Implementations§
§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> 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,
§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
§impl<T> Conv for T
impl<T> Conv for T
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§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 Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§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> 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
source§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere T: Default,
source§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> ⓘ
§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) -> Rwhere
Self: Borrow<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere Self: Borrow<B>, B: 'a + ?Sized, R: 'a,
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> Rwhere
Self: BorrowMut<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R ) -> Rwhere Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere Self: AsRef<U>, U: 'a + ?Sized, R: 'a,
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) -> Rwhere
Self: AsMut<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> Rwhere Self: AsMut<U>, U: 'a + ?Sized, R: 'a,
Mutably borrows
self
, then passes self.as_mut()
into the pipe
function.§impl<T> RawDefault for Twhere
T: Default,
impl<T> RawDefault for Twhere T: Default,
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere Self: Borrow<B>, B: ?Sized,
Immutable access to the
Borrow<B>
of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere Self: BorrowMut<B>, B: ?Sized,
Mutable access to the
BorrowMut<B>
of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere Self: AsRef<R>, R: ?Sized,
Immutable access to the
AsRef<R>
view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere Self: AsMut<R>, R: ?Sized,
Mutable access to the
AsMut<R>
view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere
Self: Deref<Target = T>,
T: ?Sized,
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere Self: Deref<Target = T>, T: ?Sized,
Immutable access to the
Deref::Target
of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere Self: DerefMut<Target = T> + Deref, T: ?Sized,
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)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere Self: Borrow<B>, B: ?Sized,
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)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere Self: BorrowMut<B>, B: ?Sized,
Calls
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere Self: AsRef<R>, R: ?Sized,
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)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere Self: AsMut<R>, R: ?Sized,
Calls
.tap_ref_mut()
only in debug builds, and is erased in release
builds.§impl<Q> ToOwnedEquivalent<<Q as ToOwned>::Owned> for Qwhere
Q: ToOwned + Eq + ?Sized,
impl<Q> ToOwnedEquivalent<<Q as ToOwned>::Owned> for Qwhere Q: ToOwned + Eq + ?Sized,
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 Twhere
T: TurboCore + GenCore + ?Sized,
impl<T> TurboRand for Twhere T: TurboCore + GenCore + ?Sized,
§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<T, 'a>(&self, list: &'a [T]) -> Option<&'a T>
fn sample<T, 'a>(&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<T, 'a>(&self, list: &'a mut [T]) -> Option<&'a mut T>
fn sample_mut<T, 'a>(&self, list: &'a mut [T]) -> Option<&'a mut T>
Samples a random
&mut
item from a slice of values. Read more§fn sample_multiple<T, 'a>(&self, list: &'a [T], amount: usize) -> Vec<&'a T>
fn sample_multiple<T, 'a>(&self, list: &'a [T], amount: usize) -> Vec<&'a T>
Samples multiple unique items from a slice of values. Read more
§fn sample_multiple_mut<T, 'a>(
&self,
list: &'a mut [T],
amount: usize
) -> Vec<&'a mut T>
fn sample_multiple_mut<T, 'a>( &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<T, F, 'a>(
&self,
list: &'a [T],
weight_sampler: F
) -> Option<&'a T>where
F: Fn((&T, usize)) -> f64,
fn weighted_sample<T, F, 'a>( &self, list: &'a [T], weight_sampler: F ) -> Option<&'a T>where F: Fn((&T, usize)) -> f64,
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<T, F, 'a>(
&self,
list: &'a mut [T],
weight_sampler: F
) -> Option<&'a mut T>where
F: Fn((&T, usize)) -> f64,
fn weighted_sample_mut<T, F, 'a>( &self, list: &'a mut [T], weight_sampler: F ) -> Option<&'a mut T>where F: Fn((&T, usize)) -> f64,
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<T, 'a>(
&self,
slice: &'a mut [T],
amount: usize
) -> (&'a mut [T], &'a mut [T])
fn partial_shuffle<T, 'a>( &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.