Expand description
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")];
Macros§
- bidir_
map - Create a
BidirMap
from a set of K/V-K/V pairs.
Structs§
- Bidir
Map - A bidirectional map.
- ByFirst
- Wrapper type for getting second keys/values with first keys/values via
Index
. - BySecond
- Wrapper type for getting second keys/values with first keys/values via
Index
. - First
Column - An iterator the first set of K/Vs in a
BidirMap
. - Iter
- An iterator over the K/V pairs contained in a
BidirMap
. - IterMut
- An iterator over mutable K/V pairs contained in a
BidirMap
. - Second
Column - An iterator the second set of K/Vs in a
BidirMap
.