Function random_string::generate

source ·
pub fn generate<S: AsRef<str>>(length: usize, charset: S) -> String
Expand description

Generates a random string with given length and charset.

Will Panic if the provided charset is empty.


  • length - Length of a String to generate
  • charset - Object implementing AsRef trait to do reference-to-reference conversion into &str


use random_string::generate;

let charset = "1234567890";
println!("{}", generate(6, charset));