pub struct RandomBlock { /* private fields */ }Expand description
A block-buffered source of unbiased, alphabet-restricted random bytes.
Each buffered byte’s low six bits select one of 64 possible values; the alphabet has only 63 characters, so a byte whose low six bits equal 63 is rejected and redrawn. Rejecting rather than reducing modulo 63 keeps every alphabet character equally likely.
Implementations§
Source§impl RandomBlock
impl RandomBlock
Sourcepub fn new(rng: ChaCha8Rng) -> Self
pub fn new(rng: ChaCha8Rng) -> Self
Create a block sampler backed by rng, filling the first block
immediately.
Sourcepub fn next_alphanumeric(&mut self) -> u8
pub fn next_alphanumeric(&mut self) -> u8
Sample a single character from the 63-character alphanumeric alphabet, uniformly at random.
Auto Trait Implementations§
impl Freeze for RandomBlock
impl RefUnwindSafe for RandomBlock
impl Send for RandomBlock
impl Sync for RandomBlock
impl Unpin for RandomBlock
impl UnsafeUnpin for RandomBlock
impl UnwindSafe for RandomBlock
Blanket Implementations§
impl<T> Allocation for T
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> 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