[−][src]Struct random_fast_rng::FastRng
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()
Methods
impl FastRng
[src]
pub fn new() -> Self
[src]
Creates a new instance of FastRng
seeded with the system time.
Examples
use random_fast_rng::{FastRng, Random}; let mut rng = FastRng::new(); let random_u8 = rng.get_u8(); let arr: [u8; 32] = rng.gen();
pub fn seed(seed: u64, seq: u64) -> Self
[src]
A function to manually seed the Rng in no-std
cases.
Trait Implementations
impl Random for FastRng
[src]
type Error = ()
The Error type, based on the source of randomness, non fallible sources can use Error=()
fn try_fill_bytes(&mut self, buf: &mut [u8]) -> Result<(), Self::Error>
[src]
fn get_u32(&mut self) -> u32
[src]
fn fill_bytes(&mut self, buf: &mut [u8])
[src]
Uses try_fill_bytes
but panics if returns an error. Override if you can gracefully handle errors in the randomness source. Read more
fn gen<T>(&mut self) -> T where
T: GenerateRand,
[src]
T: GenerateRand,
Returns a generic random value which implements GenerateRand
fn get_u8(&mut self) -> u8
[src]
Returns a random u8
number.
fn get_u16(&mut self) -> u16
[src]
Returns a random u16
number.
fn get_u64(&mut self) -> u64
[src]
Returns a random u64
number.
fn get_usize(&mut self) -> usize
[src]
Returns a random usize
number.
fn get_u128(&mut self) -> u128
[src]
Returns a random u128
number.
fn get_bool(&mut self) -> bool
[src]
Returns a random bool
with 50/50 probability.
Auto Trait Implementations
impl Unpin for FastRng
impl Send for FastRng
impl Sync for FastRng
impl UnwindSafe for FastRng
impl RefUnwindSafe for FastRng
Blanket Implementations
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,