From baac7d065a71a388476b998ba55b1c0aedaa9d86 Mon Sep 17 00:00:00 2001 From: msrd0 Date: Wed, 27 Apr 2022 20:42:29 +0200 Subject: [PATCH] Add `Map::new()` function and `Default` implementation to create new, empty map (#249) Co-authored-by: Yuki Okushi --- phf/src/map.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/phf/src/map.rs b/phf/src/map.rs index 5b74445c..9fc42df9 100644 --- a/phf/src/map.rs +++ b/phf/src/map.rs @@ -46,7 +46,23 @@ where } } +impl Default for Map { + fn default() -> Self { + Self::new() + } +} + impl Map { + /// 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 {