pub struct ThreadFastRng(/* private fields */);Expand description
A thread-local FastRng that is seeded from the global SysRng the
first time a thread uses it.
Like FastRng, it’s a small, fast, and non-cryptographic rng with decent
statistical properties. Useful for sampling non-security sensitive data.
Shines in multithreaded/async scenarios where don’t want to have to
synchronize on a single Mutex<FastRng> or deal with handing out FastRngs
to each thread. Instead we let thread-locals handle all the drudgery.
Implementations§
Trait Implementations§
Source§impl Default for ThreadFastRng
impl Default for ThreadFastRng
Source§impl RngCore for ThreadFastRng
impl RngCore for ThreadFastRng
Source§fn fill_bytes(&mut self, dest: &mut [u8])
fn fill_bytes(&mut self, dest: &mut [u8])
Fill
dest with random data. Read moreAuto Trait Implementations§
impl Freeze for ThreadFastRng
impl RefUnwindSafe for ThreadFastRng
impl Send for ThreadFastRng
impl Sync for ThreadFastRng
impl Unpin for ThreadFastRng
impl UnsafeUnpin for ThreadFastRng
impl UnwindSafe for ThreadFastRng
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<R> RngExt for Rwhere
R: RngCore,
impl<R> RngExt for Rwhere
R: RngCore,
fn gen_bytes<const N: usize>(&mut self) -> [u8; N]
fn gen_u32(&mut self) -> u32
fn gen_u64(&mut self) -> u64
fn gen_u8(&mut self) -> u8
fn gen_u16(&mut self) -> u16
fn gen_u128(&mut self) -> u128
Source§fn gen_boolean(&mut self) -> bool
fn gen_boolean(&mut self) -> bool
Flip a coin. Generate
true with probability 0.5Source§fn gen_range_i32(&mut self, range: Range<i32>) -> i32
fn gen_range_i32(&mut self, range: Range<i32>) -> i32
Generates an
i32 in [range.start, range.end). Has slight modulo
bias for large ranges. See fastmap32.Source§fn gen_range_u32(&mut self, range: Range<u32>) -> u32
fn gen_range_u32(&mut self, range: Range<u32>) -> u32
Generates a
u32 in [range.start, range.end). Has slight modulo
bias for large ranges. See fastmap32.Source§fn gen_range_u64(&mut self, range: Range<u64>) -> u64
fn gen_range_u64(&mut self, range: Range<u64>) -> u64
Generates a
u32 in [range.start, range.end). Has slight modulo
bias for large ranges. See fastmap64.