Impl a better Default for Map

master
marceline-cramer 3 years ago
parent 463e83ab31
commit f98a5fc042

@ -210,7 +210,7 @@ where K: Collapse
} }
/// A small hashtable-like map with byte sized key indecies. /// A small hashtable-like map with byte sized key indecies.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Default)] #[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[cfg_attr(feature="serde", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature="serde", derive(serde::Serialize, serde::Deserialize))]
// TODO: Replace with `SmallVec<[Page<TKey, TValue>; 1]>` when feature that adds `smallvec` is enabled (this will allocate the first page on the stack, and the rest on the heap. // TODO: Replace with `SmallVec<[Page<TKey, TValue>; 1]>` when feature that adds `smallvec` is enabled (this will allocate the first page on the stack, and the rest on the heap.
pub struct Map<TKey, TValue>(Vec<Page<TKey,TValue>>); pub struct Map<TKey, TValue>(Vec<Page<TKey,TValue>>);
@ -449,6 +449,14 @@ where K: Collapse
} }
} }
impl<K: Collapse, V> Default for Map<K,V>
{
fn default() -> Self
{
Self::new()
}
}
impl<K: Collapse, V> IntoIterator for Map<K,V> impl<K: Collapse, V> IntoIterator for Map<K,V>
{ {
type Item= (K,V); type Item= (K,V);

Loading…
Cancel
Save