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

#1518 in Algorithms

Download history 334/week @ 2024-03-13 316/week @ 2024-03-20 333/week @ 2024-03-27 380/week @ 2024-04-03 322/week @ 2024-04-10 322/week @ 2024-04-17 331/week @ 2024-04-24 372/week @ 2024-05-01 260/week @ 2024-05-08 329/week @ 2024-05-15 326/week @ 2024-05-22 240/week @ 2024-05-29 283/week @ 2024-06-05 371/week @ 2024-06-12 599/week @ 2024-06-19 586/week @ 2024-06-26

1,894 downloads per month
Used in 11 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