Macro cssparser::ascii_case_insensitive_phf_map [−][src]
macro_rules! ascii_case_insensitive_phf_map {
($name : ident -> $ValueType : ty = { $($key : tt => $value : expr), + }) => { ... };
($name : ident -> $ValueType : ty = { $($key : tt => $value : expr,) + }) => { ... };
}
Expand description
Define a function $name(&str) -> Option<&'static $ValueType>
The function finds a match for the input string
in a phf
map
and returns a reference to the corresponding value.
Matching is case-insensitive in the ASCII range.
Example:
#[macro_use] extern crate cssparser;
fn color_rgb(input: &str) -> Option<(u8, u8, u8)> {
ascii_case_insensitive_phf_map! {
keyword -> (u8, u8, u8) = {
"red" => (255, 0, 0),
"green" => (0, 255, 0),
"blue" => (0, 0, 255),
}
}
keyword(input).cloned()
}