Struct caffe2_imports::StdRng

source ·
pub struct StdRng { /* private fields */ }
Expand description

The standard RNG. This is designed to be efficient on the current platform.

Implementations§

source§

impl StdRng

source

pub fn new() -> Result<StdRng, Error>

Create a randomly seeded instance of StdRng.

This is a very expensive operation as it has to read randomness from the operating system and use this in an expensive seeding operation. If one is only generating a small number of random numbers, or doesn’t need the utmost speed for generating each number, thread_rng and/or random may be more appropriate.

Reading the randomness from the OS may fail, and any error is propagated via the io::Result return value.

Trait Implementations§

source§

impl Clone for StdRng

source§

fn clone(&self) -> StdRng

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for StdRng

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl Rng for StdRng

source§

fn next_u32(&mut self) -> u32

Return the next random u32. Read more
source§

fn next_u64(&mut self) -> u64

Return the next random u64. Read more
source§

fn next_f32(&mut self) -> f32

Return the next random f32 selected from the half-open interval [0, 1). Read more
source§

fn next_f64(&mut self) -> f64

Return the next random f64 selected from the half-open interval [0, 1). Read more
source§

fn fill_bytes(&mut self, dest: &mut [u8])

Fill dest with random data. Read more
source§

fn gen<T>(&mut self) -> Twhere T: Rand, Self: Sized,

Return a random value of a Rand type. Read more
source§

fn gen_iter<T, 'a>(&'a mut self) -> Generator<'a, T, Self> where T: Rand, Self: Sized,

Return an iterator that will yield an infinite number of randomly generated items. Read more
source§

fn gen_range<T>(&mut self, low: T, high: T) -> Twhere T: PartialOrd<T> + SampleRange, Self: Sized,

Generate a random value in the range [low, high). Read more
source§

fn gen_weighted_bool(&mut self, n: u32) -> boolwhere Self: Sized,

Return a bool with a 1 in n chance of true Read more
source§

fn gen_ascii_chars<'a>(&'a mut self) -> AsciiGenerator<'a, Self> where Self: Sized,

Return an iterator of random characters from the set A-Z,a-z,0-9. Read more
source§

fn choose<T, 'a>(&mut self, values: &'a [T]) -> Option<&'a T>where Self: Sized,

Return a random element from values. Read more
source§

fn choose_mut<T, 'a>(&mut self, values: &'a mut [T]) -> Option<&'a mut T>where Self: Sized,

Return a mutable pointer to a random element from values. Read more
source§

fn shuffle<T>(&mut self, values: &mut [T])where Self: Sized,

Shuffle a mutable slice in place. Read more
source§

impl<'a> SeedableRng<&'a [usize]> for StdRng

source§

fn reseed(&mut self, seed: &'a [usize])

Reseed an RNG with the given seed. Read more
source§

fn from_seed(seed: &'a [usize]) -> StdRng

Create a new RNG with the given seed. Read more
source§

impl Copy for StdRng

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
§

impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,

§

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

Checks if self is actually part of its subset T (and can be converted to it).
§

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

The inclusion map: converts self to the equivalent element of its superset.
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> Ungil for Twhere T: Send,