From 5bc47853d4d3e9e483545360450866d04b11f083 Mon Sep 17 00:00:00 2001 From: Diggory Hardy Date: Sat, 3 Mar 2018 11:33:55 +0000 Subject: [PATCH] Deprecate gen_ascii_chars --- src/lib.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index caf3fe73986..37cea0b58ac 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -652,11 +652,14 @@ pub trait Rng: RngCore + Sized { /// # Example /// /// ```rust + /// #[allow(deprecated)] /// use rand::{thread_rng, Rng}; /// /// let s: String = thread_rng().gen_ascii_chars().take(10).collect(); /// println!("{}", s); /// ``` + #[allow(deprecated)] + #[deprecated(since="0.5.0", note="use distributions::Alphanumeric instead")] fn gen_ascii_chars(&mut self) -> AsciiGenerator<&mut Self> { AsciiGenerator { rng: self } } @@ -871,10 +874,13 @@ impl Iterator for Generator where Uniform: Distribution /// [`gen_ascii_chars`]: trait.Rng.html#method.gen_ascii_chars /// [`Rng`]: trait.Rng.html #[derive(Debug)] +#[allow(deprecated)] +#[deprecated(since="0.5.0", note="use distributions::Alphanumeric instead")] pub struct AsciiGenerator { rng: R, } +#[allow(deprecated)] impl Iterator for AsciiGenerator { type Item = char; @@ -1206,14 +1212,6 @@ mod test { assert_eq!(r.gen_weighted_bool(1), true); } - #[test] - fn test_gen_ascii_str() { - let mut r = rng(105); - assert_eq!(r.gen_ascii_chars().take(0).count(), 0); - assert_eq!(r.gen_ascii_chars().take(10).count(), 10); - assert_eq!(r.gen_ascii_chars().take(16).count(), 16); - } - #[test] fn test_gen_vec() { let mut r = rng(106);