macro_rules! batch_keys {
($key_type:ty => [$($key_str:expr),* $(,)?]) => { ... };
}Expand description
Create multiple keys at once with error handling
This macro simplifies the creation of multiple keys from string literals or expressions, with automatic error collection.
ยงExamples
use domain_key::{define_domain, key_type, batch_keys};
define_domain!(UserDomain, "user");
key_type!(UserKey, UserDomain);
// Create multiple keys, collecting any errors
let result = batch_keys!(UserKey => [
"user_1",
"user_2",
"user_3",
]);
match result {
Ok(keys) => println!("Created {} keys", keys.len()),
Err(errors) => println!("Failed to create {} keys", errors.len()),
}