Skip to content

Commit

Permalink
Deprecate gen_ascii_chars
Browse files Browse the repository at this point in the history
  • Loading branch information
dhardy committed Mar 3, 2018
1 parent f97831d commit 3f0442f
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}
Expand Down Expand Up @@ -871,10 +874,13 @@ impl<T, R: RngCore> Iterator for Generator<T, R> where Uniform: Distribution<T>
/// [`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<R: RngCore> {
rng: R,
}

#[allow(deprecated)]
impl<R: RngCore> Iterator for AsciiGenerator<R> {
type Item = char;

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 3f0442f

Please sign in to comment.