pub struct Alphabetic;
Expand description
Sample a u8
, uniformly distributed over letters:
a-z and A-Z.
§Example
You’re able to generate random Alphabetic characters via mapping or via the
SampleString::sample_string
method like so:
use rand::Rng;
use rand::distr::{Alphabetic, SampleString};
// Manual mapping
let mut rng = rand::rng();
let chars: String = (0..7).map(|_| rng.sample(Alphabetic) as char).collect();
println!("Random chars: {}", chars);
// Using [`SampleString::sample_string`]
let string = Alphabetic.sample_string(&mut rand::rng(), 16);
println!("Random string: {}", string);
§Passwords
Refer to Alphanumeric
.
Trait Implementations§
Source§impl Clone for Alphabetic
impl Clone for Alphabetic
Source§fn clone(&self) -> Alphabetic
fn clone(&self) -> Alphabetic
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for Alphabetic
impl Debug for Alphabetic
Source§impl Default for Alphabetic
impl Default for Alphabetic
Source§fn default() -> Alphabetic
fn default() -> Alphabetic
Returns the “default value” for a type. Read more
Source§impl Distribution<u8> for Alphabetic
impl Distribution<u8> for Alphabetic
Source§impl SampleString for Alphabetic
impl SampleString for Alphabetic
impl Copy for Alphabetic
Auto Trait Implementations§
impl Freeze for Alphabetic
impl RefUnwindSafe for Alphabetic
impl Send for Alphabetic
impl Sync for Alphabetic
impl Unpin for Alphabetic
impl UnwindSafe for Alphabetic
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more