Trait MutableStringZilla
pub trait MutableStringZilla<A>{
// Required method
fn sz_randomize(&mut self, alphabet: A);
}
Available on crate feature
dep_stringzilla
only.Expand description
Provides a tool for mutating a byte slice by filling it with random data from a specified alphabet. This trait is especially useful for types that need to be mutable and can reference or be converted to byte slices.
§Examples
Filling a mutable byte buffer with random ASCII letters:
use stringzilla::MutableStringZilla;
let mut buffer = vec![0u8; 10]; // A buffer to randomize
let alphabet = b"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; // Alphabet to use
buffer.sz_randomize(alphabet);
println!("Random buffer: {:?}", buffer);
// The buffer will now contain random ASCII letters.
Required Methods§
fn sz_randomize(&mut self, alphabet: A)
fn sz_randomize(&mut self, alphabet: A)
Fills the implementing byte slice with random bytes from the specified alphabet
.
§Examples
use stringzilla::MutableStringZilla;
let mut text = vec![0; 1000]; // A buffer to randomize
let alphabet = b"AGTC"; // Using a DNA alphabet
text.sz_randomize(alphabet);
// `text` is now filled with random 'A', 'G', 'T', or 'C' values.