rand::distr

Trait SampleString

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

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

Sample or extend a String

Helper methods to extend a String or sample a new String.

Required Methods§

Source

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

Append len random chars to string

Note: implementations may leave string with excess capacity. If this is undesirable, consider calling String::shrink_to_fit after this method.

Provided Methods§

Source

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

Generate a String of len random chars

Note: implementations may leave the string with excess capacity. If this is undesirable, consider calling String::shrink_to_fit after this method.

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§