Skip to content

Commit

Permalink
Deprecate ReadRng
Browse files Browse the repository at this point in the history
  • Loading branch information
dhardy committed Jun 7, 2021
1 parent e3bc4a1 commit d167dd2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
1 change: 1 addition & 0 deletions src/rngs/adapter/mod.rs
Expand Up @@ -11,5 +11,6 @@
mod read;
mod reseeding;

#[allow(deprecated)]
pub use self::read::{ReadError, ReadRng};
pub use self::reseeding::ReseedingRng;
15 changes: 4 additions & 11 deletions src/rngs/adapter/read.rs
Expand Up @@ -9,6 +9,8 @@

//! A wrapper around any Read to treat it as an RNG.

#![allow(deprecated)]

use std::fmt;
use std::io::Read;

Expand All @@ -30,20 +32,10 @@ use rand_core::{impls, Error, RngCore};
/// have enough data, will only be reported through [`try_fill_bytes`].
/// The other [`RngCore`] methods will panic in case of an error.
///
/// # Example
///
/// ```
/// use rand::Rng;
/// use rand::rngs::adapter::ReadRng;
///
/// let data = vec![1, 2, 3, 4, 5, 6, 7, 8];
/// let mut rng = ReadRng::new(&data[..]);
/// println!("{:x}", rng.gen::<u32>());
/// ```
///
/// [`OsRng`]: crate::rngs::OsRng
/// [`try_fill_bytes`]: RngCore::try_fill_bytes
#[derive(Debug)]
#[deprecated(since="0.8.4", note="removal due to lack of usage")]
pub struct ReadRng<R> {
reader: R,
}
Expand Down Expand Up @@ -86,6 +78,7 @@ impl<R: Read> RngCore for ReadRng<R> {

/// `ReadRng` error type
#[derive(Debug)]
#[deprecated(since="0.8.4")]
pub struct ReadError(std::io::Error);

impl fmt::Display for ReadError {
Expand Down

0 comments on commit d167dd2

Please sign in to comment.