11//! # multi-map
22//!
3- //! MultiMap is like a std::collection::HashMap, but allows you to use either of
3+ //! ` MultiMap` is like a ` std::collection::HashMap` , but allows you to use either of
44//! two different keys to retrieve items.
55//!
66//! The keys have two distinct types - `K1` and `K2` - which may be the same.
77//! Accessing on the primary `K1` key is via the usual `get`, `get_mut` and
88//! `remove_alt` methods, while accessing via the secondary `K2` key is via new
99//! `get_alt`, `get_mut_alt` and `remove_alt` methods. The value is of type `V`.
1010//!
11- //! Internally, two HashMaps are created - a main one on `<K1, (K2,
11+ //! Internally, two `HashMap`s are created - a main one on `<K1, (K2,
1212//! V)>` and a second one on `<K2, K1>`. The `(K2, V)` tuple is so
1313//! that when an item is removed using the `K1` key, the appropriate `K2`
1414//! value is available so the `K2->K1` map can be removed from the second
15- //! HashMap , to keep them in sync.
15+ //! `MultiMap` , to keep them in sync.
1616//!
17- //! Using two HashMaps instead of one naturally brings a slight performance
18- //! and memory penalty. Notably, indexing by `K2` requires two HashMap lookups.
17+ //! Using two `HashMap`s instead of one naturally brings a slight performance
18+ //! and memory penalty. Notably, indexing by `K2` requires two ` HashMap` lookups.
1919//!
2020//! ```
2121//! extern crate multi_map;
@@ -112,7 +112,7 @@ impl<K1: Eq + Hash + Clone, K2: Eq + Hash + Clone, V> MultiMap<K1, K2, V> {
112112 pub fn get_alt ( & self , key : & K2 ) -> Option < & V > {
113113 let mut result = None ;
114114 if let Some ( key_a) = self . key_map . get ( key) {
115- if let Some ( pair) = self . value_map . get ( & key_a) {
115+ if let Some ( pair) = self . value_map . get ( key_a) {
116116 result = Some ( & pair. 1 )
117117 }
118118 }
@@ -124,7 +124,7 @@ impl<K1: Eq + Hash + Clone, K2: Eq + Hash + Clone, V> MultiMap<K1, K2, V> {
124124 pub fn get_mut_alt ( & mut self , key : & K2 ) -> Option < & mut V > {
125125 let mut result = None ;
126126 if let Some ( key_a) = self . key_map . get ( key) {
127- if let Some ( pair) = self . value_map . get_mut ( & key_a) {
127+ if let Some ( pair) = self . value_map . get_mut ( key_a) {
128128 result = Some ( & mut pair. 1 )
129129 }
130130 }
@@ -171,7 +171,7 @@ impl<K1: Eq + Hash + Clone, K2: Eq + Hash + Clone, V> MultiMap<K1, K2, V> {
171171}
172172
173173#[ macro_export]
174- /// Create a MultiMap from a list of key-value tuples
174+ /// Create a ` MultiMap` from a list of key-value tuples
175175///
176176/// ## Example
177177///
0 commit comments