pub struct FastRng { /* private fields */ }
Expand description
A FastRng struct implementing Random
. you can initialize it with your own seed using FastRng::seed()
Or if the std
feature is enabled call FastRng::new()
which will seed it with the system time.
For ergonomics and ease of usability the Rng is also provided as a global thread local variable using FastRng::local_rng()
Implementations§
Trait Implementations§
Source§impl Random for FastRng
impl Random for FastRng
Source§type Error = ()
type Error = ()
The Error type, based on the source of randomness, non fallible sources can use
Error=()
Source§fn try_fill_bytes(&mut self, buf: &mut [u8]) -> Result<(), Self::Error>
fn try_fill_bytes(&mut self, buf: &mut [u8]) -> Result<(), Self::Error>
This is the main method of the trait.
You should implement this on your randomness source and will the buffer with random data.
Source§fn fill_bytes(&mut self, buf: &mut [u8])
fn fill_bytes(&mut self, buf: &mut [u8])
Uses
try_fill_bytes
but panics if returns an error.
Override if you can gracefully handle errors in the randomness source.Source§fn gen<T>(&mut self) -> Twhere
T: GenerateRand,
fn gen<T>(&mut self) -> Twhere
T: GenerateRand,
Returns a generic random value which implements
GenerateRand
Auto Trait Implementations§
impl Freeze for FastRng
impl RefUnwindSafe for FastRng
impl Send for FastRng
impl Sync for FastRng
impl Unpin for FastRng
impl UnwindSafe for FastRng
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