cphf 1.0.0

Compile-time perfect hash function data structures
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
use cphf::{phf_ordered_map, OrderedMap, UncasedStr};

pub static MAP: OrderedMap<&'static UncasedStr, isize> = phf_ordered_map! {&'static UncasedStr, isize;
    UncasedStr::new("Foo") => 0,
    UncasedStr::new("Bar") => 1,
};

fn main() {
    assert_eq!(MAP.get("foo").cloned(), Some(0));
    assert_eq!(MAP.get("bAR").cloned(), Some(1));
    assert_eq!(MAP.get(&"bAR".to_owned()).cloned(), Some(1));
}