diff --git a/src/core/utils/rand.rs b/src/core/utils/rand.rs index b80671eb..d717c4bd 100644 --- a/src/core/utils/rand.rs +++ b/src/core/utils/rand.rs @@ -3,6 +3,7 @@ use std::{ time::{Duration, SystemTime}, }; +use arrayvec::ArrayString; use rand::{thread_rng, Rng}; pub fn string(length: usize) -> String { @@ -13,6 +14,18 @@ pub fn string(length: usize) -> String { .collect() } +#[inline] +pub fn string_array() -> ArrayString { + let mut ret = ArrayString::::new(); + thread_rng() + .sample_iter(&rand::distributions::Alphanumeric) + .take(LENGTH) + .map(char::from) + .for_each(|c| ret.push(c)); + + ret +} + #[inline] #[must_use] pub fn timepoint_secs(range: Range) -> SystemTime {