solana_type_overrides::rand::distributions

Trait DistString

Source
pub trait DistString {
    // Required method
    fn append_string<R>(&self, rng: &mut R, string: &mut String, len: usize)
       where R: Rng + ?Sized;

    // Provided method
    fn sample_string<R>(&self, rng: &mut R, len: usize) -> String
       where R: Rng + ?Sized { ... }
}
Expand description

String sampler

Sampling a String of random characters is not quite the same as collecting a sequence of chars. This trait contains some helpers.

Required Methods§

Source

fn append_string<R>(&self, rng: &mut R, string: &mut String, len: usize)
where R: Rng + ?Sized,

Append len random chars to string

Provided Methods§

Source

fn sample_string<R>(&self, rng: &mut R, len: usize) -> String
where R: Rng + ?Sized,

Generate a String of len random chars

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl DistString for Alphanumeric

Source§

impl DistString for Standard

Note: the String is potentially left with excess capacity; optionally the user may call string.shrink_to_fit() afterwards.