Expand documentation of ReadRng

This commit is contained in:
Diggory Hardy
2018-05-11 13:05:19 +01:00
committed by Paul Dicker
parent 73d8d066b3
commit f4d2812d45
+7 -1
View File
@@ -15,10 +15,14 @@ use std::io::Read;
use rand_core::{RngCore, Error, ErrorKind, impls};
/// An RNG that reads random bytes straight from a `Read`.
/// An RNG that reads random bytes straight from any type supporting
/// `std::io::Read`, for example files.
///
/// This will work best with an infinite reader, but that is not required.
///
/// This can be used with `/dev/urandom` on Unix but it is recommended to use
/// [`OsRng`] instead.
///
/// # Panics
///
/// `ReadRng` uses `std::io::read_exact`, which retries on interrupts. All other
@@ -35,6 +39,8 @@ use rand_core::{RngCore, Error, ErrorKind, impls};
/// let mut rng = read::ReadRng::new(&data[..]);
/// println!("{:x}", rng.gen::<u32>());
/// ```
///
/// [`OsRng`]: ../struct.OsRng.html
#[derive(Debug)]
pub struct ReadRng<R> {
reader: R