Struct af_core::random::Rng [−][src]
A random number generator.
Implementations
impl Rng
[src]
pub fn new() -> Rng
[src]
Creates a new Rng
with a random seed.
pub fn fill_bytes(&mut self, bytes: &mut [u8])
[src]
Fills a slice with random bytes.
pub fn gen<T: Random>(&mut self) -> T
[src]
Generates a random value.
pub fn gen_chance(&mut self, probability: f64) -> bool
[src]
Returns true
with a given probability.
The probability is the chance from 0.0
(never) to 1.0
(always) that
this function returns true
.
pub fn gen_range<T: SampleUniform>(&mut self, range: impl SampleRange<T>) -> T
[src]
Generates a random number within a given range.
pub fn gen_ratio<T: Number + SampleUniform>(
&mut self,
numerator: T,
denominator: T
) -> bool
[src]
&mut self,
numerator: T,
denominator: T
) -> bool
Returns true
with a probability expressed by the ratio between two given
numbers.
pub fn shuffle<T>(&mut self, slice: &mut [T])
[src]
Randomly shuffles a slice in place.
Trait Implementations
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<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut Tⓘ
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,