From b200e81d537b52e327a4056cb98cb935cad7d135 Mon Sep 17 00:00:00 2001 From: Dominic Date: Sat, 16 Apr 2022 16:51:46 +0200 Subject: [PATCH 1/3] Add `Map::new_empty()` function to create new, empty map --- phf/src/map.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/phf/src/map.rs b/phf/src/map.rs index 5b74445c..bc24faea 100644 --- a/phf/src/map.rs +++ b/phf/src/map.rs @@ -47,6 +47,16 @@ where } impl Map { + /// Create a new, empty, immutable map. + #[inline] + pub const fn new_empty() -> Self { + Self { + key: 0, + disps: &[], + entries: &[], + } + } + /// Returns the number of entries in the `Map`. #[inline] pub const fn len(&self) -> usize { From 70723438220fcb1388182e24f3d5626d3214816c Mon Sep 17 00:00:00 2001 From: msrd0 Date: Wed, 27 Apr 2022 14:27:22 +0000 Subject: [PATCH 2/3] Rename to `Map::new()` Co-authored-by: Yuki Okushi --- phf/src/map.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phf/src/map.rs b/phf/src/map.rs index bc24faea..cd868b3f 100644 --- a/phf/src/map.rs +++ b/phf/src/map.rs @@ -49,7 +49,7 @@ where impl Map { /// Create a new, empty, immutable map. #[inline] - pub const fn new_empty() -> Self { + pub const fn new() -> Self { Self { key: 0, disps: &[], From 3d99fa7eee872b7ae212846f1d00fd2755e8a2ad Mon Sep 17 00:00:00 2001 From: Dominic Date: Wed, 27 Apr 2022 16:28:24 +0200 Subject: [PATCH 3/3] add Default implementation --- phf/src/map.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/phf/src/map.rs b/phf/src/map.rs index cd868b3f..9fc42df9 100644 --- a/phf/src/map.rs +++ b/phf/src/map.rs @@ -46,6 +46,12 @@ where } } +impl Default for Map { + fn default() -> Self { + Self::new() + } +} + impl Map { /// Create a new, empty, immutable map. #[inline]