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::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`]
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 duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for Alphabetic
Source§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
Available on crate feature alloc only.
impl SampleString for Alphabetic
Available on crate feature
alloc only.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§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Converts
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Converts
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Converts
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Converts
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more