Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Map::new() function and Default implementation to create new, empty map #249

Merged
merged 3 commits into from Apr 27, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions phf/src/map.rs
Expand Up @@ -47,6 +47,16 @@ where
}

impl<K, V> Map<K, V> {
/// Create a new, empty, immutable map.
#[inline]
pub const fn new_empty() -> Self {
msrd0 marked this conversation as resolved.
Show resolved Hide resolved
Self {
key: 0,
disps: &[],
entries: &[],
}
}

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