Build Status Documentation

bimap-rs: a fast two-way bijective map for Rust

Examples

```rust use bimap::Bimap;

let mut elements = Bimap::new();

// insert chemicals and their corresponding symbols elements.insert("hydrogen", "H"); elements.insert("carbon", "C"); elements.insert("bromine", "Br"); elements.insert("neodymium", "Nd");

// retrieve chemical symbol by name (left to right) asserteq!(elements.getbyleft(&"bromine"), Some(&"Br")); asserteq!(elements.getbyleft(&"oxygen"), None);

// retrieve name by chemical symbol (right to left) asserteq!(elements.getbyright(&"C"), Some(&"carbon")); asserteq!(elements.getbyright(&"Al"), None);

// check membership assert!(elements.containsleft(&"hydrogen")); assert!(!elements.containsright(&"He"));

// remove elements asserteq!(elements.removebyleft(&"neodymium"), Some(("neodymium", "Nd"))); asserteq!(elements.removebyright(&"Nd"), None);

// iterate over elements for (left, right) in &elements { println!("the chemical symbol for {} is {}", left, right); } ```