Function fill_bytes

Source
pub fn fill_bytes<F>(buffer: &mut [u8], rng: F)
where F: FnMut() -> u64,
Expand description

Fills buffer with random bytes generated by the provided function.

This function splits the buffer into chunks of up to 8 bytes and fills each chunk with bytes derived from a u64 value generated by rng().

§Parameters

  • buffer: A mutable reference to a slice of bytes (&mut [u8]) that will be filled with random data.
  • rng: A mutable function (FnMut() -> u64) that generates random u64 values.

§Examples

let mut data = [0u8; 16];
stdrandom::fill_bytes(&mut data, stdrandom::fast_u64);

println!("{:?}", data); // Randomized output

§Safety Notes

  • The randomness depends on the quality of the provided rng() function.