Struct peroxide::macros::r_macro::ThreadRng [−][src]
pub struct ThreadRng { /* fields omitted */ }
Expand description
A reference to the thread-local generator
An instance can be obtained via thread_rng
or via ThreadRng::default()
.
This handle is safe to use everywhere (including thread-local destructors)
but cannot be passed between threads (is not Send
or Sync
).
ThreadRng
uses the same PRNG as StdRng
for security and performance
and is automatically seeded from OsRng
.
Unlike StdRng
, ThreadRng
uses the ReseedingRng
wrapper to reseed
the PRNG from fresh entropy every 64 kiB of random data as well as after a
fork on Unix (though not quite immediately; see documentation of
ReseedingRng
).
Note that the reseeding is done as an extra precaution against side-channel
attacks and mis-use (e.g. if somehow weak entropy were supplied initially).
The PRNG algorithms used are assumed to be secure.
Trait Implementations
impl CryptoRng for ThreadRng
[src]
Auto Trait Implementations
impl !RefUnwindSafe for ThreadRng
impl !Send for ThreadRng
impl !Sync for ThreadRng
impl Unpin for ThreadRng
impl !UnwindSafe for ThreadRng
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<R> Rng for R where
R: RngCore + ?Sized,
[src]
impl<R> Rng for R where
R: RngCore + ?Sized,
[src]fn gen<T>(&mut self) -> T where
Standard: Distribution<T>,
[src]
fn gen<T>(&mut self) -> T where
Standard: Distribution<T>,
[src]fn gen_range<T, R>(&mut self, range: R) -> T where
T: SampleUniform,
R: SampleRange<T>,
[src]
fn gen_range<T, R>(&mut self, range: R) -> T where
T: SampleUniform,
R: SampleRange<T>,
[src]Generate a random value in the given range. Read more
fn sample<T, D>(&mut self, distr: D) -> T where
D: Distribution<T>,
[src]
fn sample<T, D>(&mut self, distr: D) -> T where
D: Distribution<T>,
[src]Sample a new value, using the given distribution. Read more
fn sample_iter<T, D>(self, distr: D) -> DistIter<D, Self, T> where
D: Distribution<T>,
[src]
fn sample_iter<T, D>(self, distr: D) -> DistIter<D, Self, T> where
D: Distribution<T>,
[src]Create an iterator that generates values using the given distribution. Read more
fn gen_bool(&mut self, p: f64) -> bool
[src]
fn gen_bool(&mut self, p: f64) -> bool
[src]Return a bool with a probability p
of being true. Read more
fn gen_ratio(&mut self, numerator: u32, denominator: u32) -> bool
[src]
fn gen_ratio(&mut self, numerator: u32, denominator: u32) -> bool
[src]Return a bool with a probability of numerator/denominator
of being
true. I.e. gen_ratio(2, 3)
has chance of 2 in 3, or about 67%, of
returning true. If numerator == denominator
, then the returned value
is guaranteed to be true
. If numerator == 0
, then the returned
value is guaranteed to be false
. Read more
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn to_owned(&self) -> T
[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)
[src]
pub fn clone_into(&self, target: &mut T)
[src]🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,