Struct rand::rngs::ThreadRng [−][src]
pub struct ThreadRng { /* fields omitted */ }
The type returned by thread_rng
, essentially just a reference to the
PRNG in thread-local memory.
ThreadRng
uses the same PRNG as StdRng
for security and performance.
As hinted by the name, the generator is thread-local. ThreadRng
is a
handle to this generator and thus supports Copy
, but not Send
or Sync
.
Unlike StdRng
, ThreadRng
uses the ReseedingRng
wrapper to reseed
the PRNG from fresh entropy every 64 kiB of random data.
OsRng
is used to provide seed data.
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 Copy for ThreadRng
[src]
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<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]
Standard: Distribution<T>,
fn gen_range<T: SampleUniform, B1, B2>(&mut self, low: B1, high: B2) -> T where
B1: SampleBorrow<T> + Sized,
B2: SampleBorrow<T> + Sized,
[src]
B1: SampleBorrow<T> + Sized,
B2: SampleBorrow<T> + Sized,
fn sample<T, D: Distribution<T>>(&mut self, distr: D) -> T
[src]
fn sample_iter<T, D>(self, distr: D) -> DistIter<D, Self, T>ⓘ where
D: Distribution<T>,
Self: Sized,
[src]
D: Distribution<T>,
Self: Sized,
fn fill<T: AsByteSliceMut + ?Sized>(&mut self, dest: &mut T)
[src]
fn try_fill<T: AsByteSliceMut + ?Sized>(
&mut self,
dest: &mut T
) -> Result<(), Error>
[src]
&mut self,
dest: &mut T
) -> Result<(), Error>