phf_set!() { /* proc-macro */ }Expand description
Macro to create a static (compile-time) Set.
Requires the macros feature.
§Example
use phf::{phf_set, Set};
static MY_SET: Set<&'static str> = phf_set! {
"hello world",
"hola mundo",
};
fn main () {
assert!(MY_SET.contains("hello world"));
}§OR Patterns
You can use OR patterns to include multiple keys in a single entry:
use phf::{phf_set, Set};
static KEYWORDS: Set<&'static str> = phf_set! {
"if" | "elif" | "else",
"for" | "while" | "loop",
"fn" | "function" | "def",
};
fn main() {
assert!(KEYWORDS.contains("if"));
assert!(KEYWORDS.contains("elif"));
assert!(KEYWORDS.contains("else"));
assert!(KEYWORDS.contains("for"));
}