Compiler plugin defining macros that create PHF data structures.
Example
extern crate phf;
static KEYWORDS: Map = phf_map! ;
#
Compiler plugin defining macros that create PHF data structures.
#![feature(plugin, core)]
#![plugin(phf_macros)]
extern crate phf;
#[derive(Clone)]
pub enum Keyword {
Loop,
Continue,
Break,
Fn,
Extern,
}
static KEYWORDS: phf::Map<&'static str, Keyword> = phf_map! {
"loop" => Keyword::Loop,
"continue" => Keyword::Continue,
"break" => Keyword::Break,
"fn" => Keyword::Fn,
"extern" => Keyword::Extern,
};
pub fn parse_keyword(keyword: &str) -> Option<Keyword> {
KEYWORDS.get(keyword).cloned()
}
# fn main() {}