Skip to content

Commit 3f0442f

Browse files
committed
Deprecate gen_ascii_chars
1 parent f97831d commit 3f0442f

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/lib.rs

+6-8
Original file line numberDiff line numberDiff line change
@@ -652,11 +652,14 @@ pub trait Rng: RngCore + Sized {
652652
/// # Example
653653
///
654654
/// ```rust
655+
/// #[allow(deprecated)]
655656
/// use rand::{thread_rng, Rng};
656657
///
657658
/// let s: String = thread_rng().gen_ascii_chars().take(10).collect();
658659
/// println!("{}", s);
659660
/// ```
661+
#[allow(deprecated)]
662+
#[deprecated(since="0.5.0", note="use distributions::Alphanumeric instead")]
660663
fn gen_ascii_chars(&mut self) -> AsciiGenerator<&mut Self> {
661664
AsciiGenerator { rng: self }
662665
}
@@ -871,10 +874,13 @@ impl<T, R: RngCore> Iterator for Generator<T, R> where Uniform: Distribution<T>
871874
/// [`gen_ascii_chars`]: trait.Rng.html#method.gen_ascii_chars
872875
/// [`Rng`]: trait.Rng.html
873876
#[derive(Debug)]
877+
#[allow(deprecated)]
878+
#[deprecated(since="0.5.0", note="use distributions::Alphanumeric instead")]
874879
pub struct AsciiGenerator<R: RngCore> {
875880
rng: R,
876881
}
877882

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

@@ -1206,14 +1212,6 @@ mod test {
12061212
assert_eq!(r.gen_weighted_bool(1), true);
12071213
}
12081214

1209-
#[test]
1210-
fn test_gen_ascii_str() {
1211-
let mut r = rng(105);
1212-
assert_eq!(r.gen_ascii_chars().take(0).count(), 0);
1213-
assert_eq!(r.gen_ascii_chars().take(10).count(), 10);
1214-
assert_eq!(r.gen_ascii_chars().take(16).count(), 16);
1215-
}
1216-
12171215
#[test]
12181216
fn test_gen_vec() {
12191217
let mut r = rng(106);

0 commit comments

Comments
 (0)