[][src]Struct rand::read::ReadRng

pub struct ReadRng<R> { /* fields omitted */ }

An RNG that reads random bytes straight from a Read. This will work best with an infinite reader, but this is not required.

Panics

It will panic if it there is insufficient data to fulfill a request.

Example

use rand::{read, Rng};

let data = vec![1, 2, 3, 4, 5, 6, 7, 8];
let mut rng = read::ReadRng::new(&data[..]);
println!("{:x}", rng.gen::<u32>());

Methods

impl<R: Read> ReadRng<R>[src]

pub fn new(r: R) -> ReadRng<R>[src]

Create a new ReadRng from a Read.

Trait Implementations

impl<R: Read> Rng for ReadRng<R>[src]

impl<R: Debug> Debug for ReadRng<R>[src]

Auto Trait Implementations

impl<R> Send for ReadRng<R> where
    R: Send

impl<R> Unpin for ReadRng<R> where
    R: Unpin

impl<R> Sync for ReadRng<R> where
    R: Sync

impl<R> UnwindSafe for ReadRng<R> where
    R: UnwindSafe

impl<R> RefUnwindSafe for ReadRng<R> where
    R: RefUnwindSafe

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]