MCPcopy Create free account
hub / github.com/ashvardanian/StringZilla / fill_random

Function fill_random

rust/stringzilla.rs:2118–2126  ·  view source on GitHub ↗

Randomizes the contents of a given byte slice `text` using characters from a specified `alphabet`. This function mutates `text` in place, replacing each byte with a random one from `alphabet`. It is designed for situations where you need to generate random strings or data sequences based on a specific set of characters, such as generating random DNA sequences or testing inputs. # Arguments `buff

(buffer: &mut T, nonce: u64)

Source from the content-addressed store, hash-verified

2116///
2117/// After than, `buffer` is filled with random byte values from 0 to 255.
2118pub fn fill_random<T>(buffer: &mut T, nonce: u64)
2119where
2120 T: AsMut<[u8]> + ?Sized, // Allows for mutable references to dynamically sized types.
2121{
2122 let buffer_slice = buffer.as_mut();
2123 unsafe {
2124 sz_fill_random(buffer_slice.as_ptr() as _, buffer_slice.len(), nonce);
2125 }
2126}
2127
2128/// A helper type that holds a mapper closure which, given an index,
2129/// returns the corresponding byte-slice representation.

Callers

nothing calls this directly

Calls 3

as_ptrMethod · 0.80
lenMethod · 0.80
sz_fill_randomFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…