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

#1857 in Algorithms

Download history 176/week @ 2024-09-12 193/week @ 2024-09-19 189/week @ 2024-09-26 141/week @ 2024-10-03 142/week @ 2024-10-10 158/week @ 2024-10-17 73/week @ 2024-10-24 274/week @ 2024-10-31 57/week @ 2024-11-07 105/week @ 2024-11-14 129/week @ 2024-11-21 159/week @ 2024-11-28 144/week @ 2024-12-05 226/week @ 2024-12-12 131/week @ 2024-12-19 141/week @ 2024-12-26

660 downloads per month
Used in 9 crates (8 directly)

MIT license

18KB
217 lines

bidir-map-rs TravisCI build status AppVeyorCI build status Licence

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