bimap-rs
bimap-rs
is a two-way bijective map implementation for Rust.
Usage
Installation
To use bimap-rs
in your Rust project, add the following to your Cargo.toml
:
= "0.2"
no_std
compatibility
To use bimap-rs
without the Rust standard library, add the following to your Cargo.toml
:
= { = "0.2", = false }
Note that you'll need to use Rust nightly due to the use of the alloc
feature.
If you do use bimap
without the standard library, there is no BiHashMap
, only BiBTreeMap
.
Example
use BiMap;
let mut elements = new;
// insert chemicals and their corresponding symbols
elements.insert;
elements.insert;
elements.insert;
elements.insert;
// retrieve chemical symbol by name (left to right)
assert_eq!;
assert_eq!;
// retrieve name by chemical symbol (right to left)
assert_eq!;
assert_eq!;
// check membership
assert!;
assert!;
// remove elements
assert_eq!;
assert_eq!;
// iterate over elements
for in &elements
See the docs for more details.
License
bimap-rs
is licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE)
- MIT license (LICENSE-MIT)
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.