Skip to content

Commit

Permalink
Add Map::new() function and Default implementation to create new,…
Browse files Browse the repository at this point in the history
… empty map (#249)

Co-authored-by: Yuki Okushi <jtitor@2k36.org>
  • Loading branch information
msrd0 and JohnTitor committed Apr 27, 2022
1 parent 55826a9 commit baac7d0
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions phf/src/map.rs
Expand Up @@ -46,7 +46,23 @@ where
}
}

impl<K, V> Default for Map<K, V> {
fn default() -> Self {
Self::new()
}
}

impl<K, V> Map<K, V> {
/// Create a new, empty, immutable map.
#[inline]
pub const fn new() -> Self {
Self {
key: 0,
disps: &[],
entries: &[],
}
}

/// Returns the number of entries in the `Map`.
#[inline]
pub const fn len(&self) -> usize {
Expand Down

0 comments on commit baac7d0

Please sign in to comment.