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) -> Alphabetic

impl Copy for Alphabetic

impl Debug for Alphabetic

fn fmt(&self, f: &mut Formatter<'_>) -> Result

impl Default for Alphabetic

fn default() -> Alphabetic

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,

fn type_id(&self) -> TypeId

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

fn borrow(&self) -> &T

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

fn borrow_mut(&mut self) -> &mut T

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

unsafe fn clone_to_uninit(&self, dest: *mut u8)

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

impl<T> From<T> for Alphabetic

fn from(t: T) -> T

Returns the argument unchanged.

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

type Owned = T;
fn to_owned(&self) -> T
fn clone_into(&self, target: &mut T)

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

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

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

type Error = Infallible;
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

type Error = <U as TryFrom<T>>::Error;
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>