Remove default_map

This commit is contained in:
bjorn3
2021-10-12 15:07:49 +02:00
parent 6b32fcfcea
commit b0b8c1edbf
2 changed files with 0 additions and 21 deletions

View File

@@ -1,20 +0,0 @@
//! Trait for extending `HashMap` with `get_or_default`.
use std::collections::HashMap;
use std::hash::Hash;
pub(crate) trait MapWithDefault<K, V: Default> {
fn get_or_default(&mut self, k: K) -> &mut V;
}
impl<K: Eq + Hash, V: Default> MapWithDefault<K, V> for HashMap<K, V> {
fn get_or_default(&mut self, k: K) -> &mut V {
self.entry(k).or_insert_with(V::default)
}
}
#[test]
fn test_default() {
let mut hash_map = HashMap::new();
hash_map.insert(42, "hello");
assert_eq!(*hash_map.get_or_default(43), "");
}

View File

@@ -11,7 +11,6 @@ mod gen_inst;
mod gen_settings;
mod gen_types;
mod default_map;
mod shared;
mod unique_table;