macro_toolset

Macro random_string

Source
macro_rules! random_string {
    ($range:expr, $charset:expr => $string:expr) => { ... };
    ($range:expr, $charset:expr) => { ... };
    ($range:expr => $string:expr) => { ... };
    ($range:expr) => { ... };
}
Expand description

Generate random String.

For PushAnyT::push_any, random_str is recommended.

ยงExample

Just add rand = "0.8.5" to your crate deps then try:

// Use default charset `b"0123456789abcdef"` **NOT RECOMMEND, use RandHexStr instead**
let rs_1 = random_string!(32);
// Use custom charset
let rs_2 = random_string!(32, b"0123456789abcdefABCDEF");
// Provide your own string and the randon string will be appended to it
random_string!(32 => your_own_string);
// Of course, custom charset is supported
random_string!(32, b"0123456789abcdefABCDEF" => your_own_string);