11 releases (1 stable)

Uses old Rust 2015

1.0.0 Oct 21, 2017
0.6.0 Sep 2, 2017
0.5.0 Aug 27, 2017
0.3.2 Jan 20, 2017
0.2.1 Mar 28, 2016

#589 in Algorithms

Download history 95/week @ 2021-01-10 102/week @ 2021-01-17 111/week @ 2021-01-24 97/week @ 2021-01-31 111/week @ 2021-02-07 114/week @ 2021-02-14 79/week @ 2021-02-21 90/week @ 2021-02-28 92/week @ 2021-03-07 77/week @ 2021-03-14 108/week @ 2021-03-21 114/week @ 2021-03-28 89/week @ 2021-04-04 114/week @ 2021-04-11 128/week @ 2021-04-18 104/week @ 2021-04-25

445 downloads per month
Used in less than 7 crates

MIT license

17KB
217 lines

bidir-map-rs TravisCI build status AppVeyorCI build status Licence Crates.io version

Bidirectional maps for Rust

Docs


lib.rs:

Bidirectional maps for Rust.

Examples

use bidir_map::{BidirMap, ByFirst, BySecond};
use std::default::Default;

let mut map = BidirMap::new();
assert_eq!(map, Default::default());

map.insert(1, "a");

assert_eq!(map.get_by_first(&1), Some(&"a"));
assert_eq!(map.get_by_first(&2), None);
assert_eq!(map.get_by_second(&"a"), Some(&1));
assert_eq!(map.get_by_second(&"b"), None);

assert_eq!(map[ByFirst(&1)], "a");
assert_eq!(map[BySecond(&"a")], 1);
// These would panic:
//   map[ByFirst(&2)];
//   map[BySecond(&"b")];

No runtime deps