Require any Router also implements MessageRouter
[rust-lightning] / lightning / src / util / indexed_map.rs
index bb17d3450ee5ccb7193ebecd00583603071ba435..39565f048c07a25f30a6749b5057a55a15278664 100644 (file)
@@ -39,6 +39,14 @@ impl<K: Clone + Hash + Ord, V> IndexedMap<K, V> {
                }
        }
 
+       /// Constructs a new, empty map with the given capacity pre-allocated
+       pub fn with_capacity(capacity: usize) -> Self {
+               Self {
+                       map: HashMap::with_capacity(capacity),
+                       keys: Vec::with_capacity(capacity),
+               }
+       }
+
        #[inline(always)]
        /// Fetches the element with the given `key`, if one exists.
        pub fn get(&self, key: &K) -> Option<&V> {