Struct Alphabetic
pub struct Alphabetic;
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::RngExt;
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`](SampleString::sample_string)
let string = Alphabetic.sample_string(&mut rand::rng(), 16);
println!("Random string: {}", string);
Passwords
Refer to [Alphanumeric#Passwords].
Trait Implementations
impl Clone for Alphabetic
fn clone(&self) -> Self
impl Copy for Alphabetic
impl Debug for Alphabetic
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl Default for Alphabetic
fn default() -> Self
impl Distribution<u8> for Alphabetic
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> u8
impl SampleString for Alphabetic
fn append_string<R: Rng + ?Sized>(&self, rng: &mut R, string: &mut String, len: usize)
impl Serialize for Alphabetic
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where __S: Serializer,
impl<'de> Deserialize<'de> for Alphabetic
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where __D: Deserializer<'de>,