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

#1991 in Data structures

Download history 116/week @ 2024-12-21 168/week @ 2024-12-28 190/week @ 2025-01-04 235/week @ 2025-01-11 232/week @ 2025-01-18 134/week @ 2025-01-25 241/week @ 2025-02-01 212/week @ 2025-02-08 185/week @ 2025-02-15 197/week @ 2025-02-22 237/week @ 2025-03-01 205/week @ 2025-03-08 238/week @ 2025-03-15 258/week @ 2025-03-22 246/week @ 2025-03-29 271/week @ 2025-04-05

1,071 downloads per month
Used in 9 crates (8 directly)

MIT license

18KB
217 lines

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")];

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

Bidirectional maps for Rust

Docs

No runtime deps