This repository has been archived on 2024-06-08. You can view files and clone it, but cannot push or open issues or pull requests.
powd/src/utils.rs

13 lines
326 B
Rust

pub fn get_random(len: usize) -> String {
use std::iter;
use rand::{distributions::Alphanumeric, rngs::ThreadRng, thread_rng, Rng};
let mut rng: ThreadRng = thread_rng();
iter::repeat(())
.map(|()| rng.sample(Alphanumeric))
.map(char::from)
.take(len)
.collect::<String>()
}