A set of builders to generate Rust source for PHF data structures at compile time.
The provided builders are intended to be used in a Cargo build script to generate a Rust source file that will be included in a library at build time.
Examples
build.rs
extern crate phf_codegen;
use File;
use ;
use AsPath;
use env;
lib.rs
extern crate phf;
#[derive(Clone)]
enum Keyword {
Loop,
Continue,
Break,
Fn,
Extern,
}
include!(concat!(env!("OUT_DIR"), "/codegen.rs"));
pub fn parse_keyword(keyword: &str) -> Option<Keyword> {
KEYWORDS.get(keyword).cloned()
}