Skip to main content

Module rand

Module rand 

Source
Expand description

Random value generation and randomized truncation helpers.

These helpers use the thread-local generator for strings, indexes, shuffles, durations, and event identifiers. Range arguments use half-open semantics.

Functionsยง

event_id
Generates a Matrix event identifier from 32 random bytes.
index
Chooses a uniformly random index below len.
secs
Generates a Duration with a random whole-second length.
shuffle
Randomly permutes a slice in place.
string
Generates an alphanumeric ASCII string of the requested byte length.
string_array
Generates an alphanumeric ASCII string that fills a fixed-capacity array.
string_from
Generates a string of length characters sampled from charset.
time_from_now_secs
Adds a random whole-second offset to the current SystemTime.
truncate_str
Borrows a prefix ending at a randomly selected character count.
truncate_string
Truncates an owned string at a randomly selected character count.