@@ -5,8 +5,6 @@ use core::ops::Index;
55use core:: slice;
66use phf_shared:: { self , HashKey , PhfBorrow , PhfHash } ;
77
8- use crate :: Slice ;
9-
108/// An order-preserving immutable map constructed at compile time.
119///
1210/// Unlike a `Map`, iteration order is guaranteed to match the definition
@@ -21,11 +19,11 @@ pub struct OrderedMap<K: 'static, V: 'static> {
2119 #[ doc( hidden) ]
2220 pub key : HashKey ,
2321 #[ doc( hidden) ]
24- pub disps : Slice < ( u32 , u32 ) > ,
22+ pub disps : & ' static [ ( u32 , u32 ) ] ,
2523 #[ doc( hidden) ]
26- pub idxs : Slice < usize > ,
24+ pub idxs : & ' static [ usize ] ,
2725 #[ doc( hidden) ]
28- pub entries : Slice < ( K , V ) > ,
26+ pub entries : & ' static [ ( K , V ) ] ,
2927}
3028
3129impl < K , V > fmt:: Debug for OrderedMap < K , V >
@@ -51,13 +49,15 @@ where
5149}
5250
5351impl < K , V > OrderedMap < K , V > {
54- /// Returns the number of entries in the `Map`.
55- pub fn len ( & self ) -> usize {
52+ /// Returns the number of entries in the `OrderedMap`.
53+ #[ inline]
54+ pub const fn len ( & self ) -> usize {
5655 self . entries . len ( )
5756 }
5857
59- /// Returns true if the `Map` is empty.
60- pub fn is_empty ( & self ) -> bool {
58+ /// Returns true if the `OrderedMap` is empty.
59+ #[ inline]
60+ pub const fn is_empty ( & self ) -> bool {
6161 self . len ( ) == 0
6262 }
6363
@@ -82,7 +82,7 @@ impl<K, V> OrderedMap<K, V> {
8282 self . get_entry ( key) . map ( |e| e. 0 )
8383 }
8484
85- /// Determines if `key` is in the `Map `.
85+ /// Determines if `key` is in the `OrderedMap `.
8686 pub fn contains_key < T : ?Sized > ( & self , key : & T ) -> bool
8787 where
8888 T : Eq + PhfHash ,
@@ -121,7 +121,7 @@ impl<K, V> OrderedMap<K, V> {
121121 T : Eq + PhfHash ,
122122 K : PhfBorrow < T > ,
123123 {
124- if self . disps . len ( ) == 0 {
124+ if self . disps . is_empty ( ) {
125125 return None ;
126126 } //Prevent panic on empty map
127127 let hashes = phf_shared:: hash ( key, & self . key ) ;
0 commit comments