Struct rand::rngs::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
Auto Trait Implementations
impl !RefUnwindSafe for ThreadRng
impl !UnwindSafe for ThreadRng
Blanket Implementations
Mutably borrows from an owned value. Read more