Struct rand::distributions::Alphanumeric
source · [−]pub struct Alphanumeric;
Expand description
Sample a char
, uniformly distributed over ASCII letters and numbers:
a-z, A-Z and 0-9.
Example
use std::iter;
use rand::{Rng, thread_rng};
use rand::distributions::Alphanumeric;
let mut rng = thread_rng();
let chars: String = iter::repeat(())
.map(|()| rng.sample(Alphanumeric))
.take(7)
.collect();
println!("Random chars: {}", chars);
Trait Implementations
sourceimpl Debug for Alphanumeric
impl Debug for Alphanumeric
sourceimpl Distribution<char> for Alphanumeric
impl Distribution<char> for Alphanumeric
sourcefn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> char
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> char
Generate a random value of T
, using rng
as the source of randomness.
sourcefn sample_iter<'a, R>(&'a self, rng: &'a mut R) -> DistIter<'a, Self, R, T>ⓘNotable traits for DistIter<'a, D, R, T>impl<'a, D, R, T> Iterator for DistIter<'a, D, R, T> where
D: Distribution<T>,
R: Rng + 'a, type Item = T;
where
Self: Sized,
R: Rng,
fn sample_iter<'a, R>(&'a self, rng: &'a mut R) -> DistIter<'a, Self, R, T>ⓘNotable traits for DistIter<'a, D, R, T>impl<'a, D, R, T> Iterator for DistIter<'a, D, R, T> where
D: Distribution<T>,
R: Rng + 'a, type Item = T;
where
Self: Sized,
R: Rng,
D: Distribution<T>,
R: Rng + 'a, type Item = T;
Create an iterator that generates random values of T
, using rng
as
the source of randomness. Read more
Auto Trait Implementations
impl RefUnwindSafe for Alphanumeric
impl Send for Alphanumeric
impl Sync for Alphanumeric
impl Unpin for Alphanumeric
impl UnwindSafe for Alphanumeric
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more