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
Required Methods§
Sourcefn append_string<R: Rng + ?Sized>(
&self,
rng: &mut R,
string: &mut String,
len: usize,
)
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§
Sourcefn sample_string<R: Rng + ?Sized>(&self, rng: &mut R, len: usize) -> String
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§
impl SampleString for Choose<'_, char>
Available on crate feature
alloc
only.impl SampleString for Alphabetic
Available on crate feature
alloc
only.impl SampleString for Alphanumeric
Available on crate feature
alloc
only.impl SampleString for StandardUniform
Available on crate feature
alloc
only.impl SampleString for Uniform<char>
Available on crate feature
alloc
only.