Crate phf_macros[][src]

Compiler plugin defining macros that create PHF data structures.

Example

#![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()
}

Modules

util

Macros

phf_map

Constructs a phf::Map at compile time.

phf_ordered_map

Constructs a phf::OrderedMap at compile time.

phf_ordered_set

Constructs a phf::OrderedSet at compile time.

phf_set

Constructs a phf::Set at compile time.