Skip to main content

generate_unique

Function generate_unique 

Source
pub fn generate_unique(
    existing: &HashSet<String>,
) -> Result<String, &'static str>
Expand description

Generate a code that does not collide with any entry in existing. Returns Err after MAX_ATTEMPTS collisions — caller should surface that as a 5xx-equivalent: the keyspace is large (32^8 ≈ 10^12), so 500 collisions in a row means something else is wrong (e.g. RNG broken).