taiwan_id

Function generate_prefix

Source
pub fn generate_prefix(prefix: &str) -> String
Expand description

Generate a random ID with the given prefix.

For more information, please refere to wiki

ยงExamples

// Generate a random ID for Taipei City:
let id = taiwan_id::generate_prefix("A");
assert!(id.starts_with("A"));
assert!(taiwan_id::is_valid(&id));

// Generate a random female ID for Taipei City
let id = taiwan_id::generate_prefix("A2");
assert!(id.starts_with("A2"));
assert!(taiwan_id::is_valid(&id));