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>,

Auto Trait Implementations

impl Freeze for Alphabetic

impl RefUnwindSafe for Alphabetic

impl Send for Alphabetic

impl Sync for Alphabetic

impl Unpin for Alphabetic

impl UnsafeUnpin for Alphabetic

impl UnwindSafe for Alphabetic

Blanket Implementations

impl<T> Any for Alphabetic where T: 'static + ?Sized,

impl<T> Borrow<T> for Alphabetic where T: ?Sized,

impl<T> BorrowMut<T> for Alphabetic where T: ?Sized,

impl<T> CloneToUninit for Alphabetic where T: Clone,

impl<T> DeserializeOwned for Alphabetic where T: for<'de> Deserialize<'de>,

impl<T> From<T> for Alphabetic

impl<T> ToOwned for Alphabetic where T: Clone,

impl<T, U> Into<U> for Alphabetic where U: From<T>,

impl<T, U> TryFrom<U> for Alphabetic where U: Into<T>,

impl<T, U> TryInto<U> for Alphabetic where U: TryFrom<T>,