4 releases

0.0.5 Jan 25, 2024
0.0.4 Aug 29, 2023
0.0.2 Aug 29, 2023
0.0.1 Aug 29, 2023

#538 in Data structures

Download history 13/week @ 2024-02-25 56/week @ 2024-03-31

56 downloads per month

MIT license

7KB
135 lines

UID UidStore

Generate a random string of a fixed length using any roman letter or numeral.

let uid = random_string(8);

Generate a random string of a fixed length using any roman letter or numeral except letters often confused by people due to difficult to read fonts. Excludes the letters 0 o O l L i I.

let uid = human_random_string(8);

Create a bucket that can be used to generate a random string that does not match any previously generated string:

let mut u = UidStore::new(10);
let id = u.next().to_string();

Generate a new uid if this uid is already in the bucket.

let uid = "0123456789";
let o = u.make_unique(uid);
if o.is_some() {
    println!("New UID generated. {}", o.unwrap());
}

Dependencies

~310KB