Crate hashmatch

Crate hashmatch 

Source
Expand description

More efficient static &str matching when match #arm > 30.

use hashmatch::{hash_arm, hash_str};
// to avoid hash conflict
#[deny(unreachable_patterns)]
let res = match hash_str("ABC") {
    hash_arm!("ABC") => 1,
    hash_arm!("AAA") | hash_arm!("BBB") => 2,
    _ => 3,
};
assert_eq!(res, 1);

Macros§

hash_arm
Obtain hash of literals (&’static str)

Functions§

hash_str
Runtime hash with consistency of hash_arm! (hash_arm! is compling time)