/rust/registry/src/index.crates.io-1949cf8c6b5b557f/phf_shared-0.11.3/src/lib.rs
Line | Count | Source |
1 | | //! See [the `phf` crate's documentation][phf] for details. |
2 | | //! |
3 | | //! [phf]: https://docs.rs/phf |
4 | | |
5 | | #![doc(html_root_url = "https://docs.rs/phf_shared/0.11")] |
6 | | #![cfg_attr(not(feature = "std"), no_std)] |
7 | | |
8 | | #[cfg(feature = "std")] |
9 | | extern crate std as core; |
10 | | |
11 | | use core::fmt; |
12 | | use core::hash::{Hash, Hasher}; |
13 | | use core::num::Wrapping; |
14 | | use siphasher::sip128::{Hash128, Hasher128, SipHasher13}; |
15 | | |
16 | | #[non_exhaustive] |
17 | | pub struct Hashes { |
18 | | pub g: u32, |
19 | | pub f1: u32, |
20 | | pub f2: u32, |
21 | | } |
22 | | |
23 | | /// A central typedef for hash keys |
24 | | /// |
25 | | /// Makes experimentation easier by only needing to be updated here. |
26 | | pub type HashKey = u64; |
27 | | |
28 | | #[inline] |
29 | 0 | pub fn displace(f1: u32, f2: u32, d1: u32, d2: u32) -> u32 { |
30 | 0 | (Wrapping(d2) + Wrapping(f1) * Wrapping(d1) + Wrapping(f2)).0 |
31 | 0 | } Unexecuted instantiation: phf_shared::displace Unexecuted instantiation: phf_shared::displace Unexecuted instantiation: phf_shared::displace |
32 | | |
33 | | /// `key` is from `phf_generator::HashState`. |
34 | | #[inline] |
35 | 0 | pub fn hash<T: ?Sized + PhfHash>(x: &T, key: &HashKey) -> Hashes { |
36 | 0 | let mut hasher = SipHasher13::new_with_keys(0, *key); |
37 | 0 | x.phf_hash(&mut hasher); |
38 | | |
39 | | let Hash128 { |
40 | 0 | h1: lower, |
41 | 0 | h2: upper, |
42 | 0 | } = hasher.finish128(); |
43 | | |
44 | 0 | Hashes { |
45 | 0 | g: (lower >> 32) as u32, |
46 | 0 | f1: lower as u32, |
47 | 0 | f2: upper as u32, |
48 | 0 | } |
49 | 0 | } Unexecuted instantiation: phf_shared::hash::<str> Unexecuted instantiation: phf_shared::hash::<_> |
50 | | |
51 | | /// Return an index into `phf_generator::HashState::map`. |
52 | | /// |
53 | | /// * `hash` is from `hash()` in this crate. |
54 | | /// * `disps` is from `phf_generator::HashState::disps`. |
55 | | /// * `len` is the length of `phf_generator::HashState::map`. |
56 | | #[inline] |
57 | 0 | pub fn get_index(hashes: &Hashes, disps: &[(u32, u32)], len: usize) -> u32 { |
58 | 0 | let (d1, d2) = disps[(hashes.g % (disps.len() as u32)) as usize]; |
59 | 0 | displace(hashes.f1, hashes.f2, d1, d2) % (len as u32) |
60 | 0 | } Unexecuted instantiation: phf_shared::get_index Unexecuted instantiation: phf_shared::get_index Unexecuted instantiation: phf_shared::get_index |
61 | | |
62 | | /// A trait implemented by types which can be used in PHF data structures. |
63 | | /// |
64 | | /// This differs from the standard library's `Hash` trait in that `PhfHash`'s |
65 | | /// results must be architecture independent so that hashes will be consistent |
66 | | /// between the host and target when cross compiling. |
67 | | pub trait PhfHash { |
68 | | /// Feeds the value into the state given, updating the hasher as necessary. |
69 | | fn phf_hash<H: Hasher>(&self, state: &mut H); |
70 | | |
71 | | /// Feeds a slice of this type into the state provided. |
72 | 0 | fn phf_hash_slice<H: Hasher>(data: &[Self], state: &mut H) |
73 | 0 | where |
74 | 0 | Self: Sized, |
75 | | { |
76 | 0 | for piece in data { |
77 | 0 | piece.phf_hash(state); |
78 | 0 | } |
79 | 0 | } |
80 | | } |
81 | | |
82 | | /// Trait for printing types with `const` constructors, used by `phf_codegen` and `phf_macros`. |
83 | | pub trait FmtConst { |
84 | | /// Print a `const` expression representing this value. |
85 | | fn fmt_const(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result; |
86 | | } |
87 | | |
88 | | /// Identical to `std::borrow::Borrow` except omitting blanket impls to facilitate other |
89 | | /// borrowing patterns. |
90 | | /// |
91 | | /// The same semantic requirements apply: |
92 | | /// |
93 | | /// > In particular `Eq`, `Ord` and `Hash` must be equivalent for borrowed and owned values: |
94 | | /// `x.borrow() == y.borrow()` should give the same result as `x == y`. |
95 | | /// |
96 | | /// (This crate's API only requires `Eq` and `PhfHash`, however.) |
97 | | /// |
98 | | /// ### Motivation |
99 | | /// The conventional signature for lookup methods on collections looks something like this: |
100 | | /// |
101 | | /// ```ignore |
102 | | /// impl<K, V> Map<K, V> where K: PhfHash + Eq { |
103 | | /// fn get<T: ?Sized>(&self, key: &T) -> Option<&V> where T: PhfHash + Eq, K: Borrow<T> { |
104 | | /// ... |
105 | | /// } |
106 | | /// } |
107 | | /// ``` |
108 | | /// |
109 | | /// This allows the key type used for lookup to be different than the key stored in the map so for |
110 | | /// example you can use `&str` to look up a value in a `Map<String, _>`. However, this runs into |
111 | | /// a problem in the case where `T` and `K` are both a `Foo<_>` type constructor but |
112 | | /// the contained type is different (even being the same type with different lifetimes). |
113 | | /// |
114 | | /// The main issue for this crate's API is that, with this method signature, you cannot perform a |
115 | | /// lookup on a `Map<UniCase<&'static str>, _>` with a `UniCase<&'a str>` where `'a` is not |
116 | | /// `'static`; there is no impl of `Borrow` that resolves to |
117 | | /// `impl Borrow<UniCase<'a>> for UniCase<&'static str>` and one cannot be added either because of |
118 | | /// all the blanket impls. |
119 | | /// |
120 | | /// Instead, this trait is implemented conservatively, without blanket impls, so that impls like |
121 | | /// this may be added. This is feasible since the set of types that implement `PhfHash` is |
122 | | /// intentionally small. |
123 | | /// |
124 | | /// This likely won't be fixable with specialization alone but will require full support for lattice |
125 | | /// impls since we technically want to add overlapping blanket impls. |
126 | | pub trait PhfBorrow<B: ?Sized> { |
127 | | /// Convert a reference to `self` to a reference to the borrowed type. |
128 | | fn borrow(&self) -> &B; |
129 | | } |
130 | | |
131 | | /// Create an impl of `FmtConst` delegating to `fmt::Debug` for types that can deal with it. |
132 | | /// |
133 | | /// Ideally with specialization this could be just one default impl and then specialized where |
134 | | /// it doesn't apply. |
135 | | macro_rules! delegate_debug ( |
136 | | ($ty:ty) => { |
137 | | impl FmtConst for $ty { |
138 | 0 | fn fmt_const(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
139 | 0 | write!(f, "{:?}", self) |
140 | 0 | } Unexecuted instantiation: <alloc::string::String as phf_shared::FmtConst>::fmt_const Unexecuted instantiation: <str as phf_shared::FmtConst>::fmt_const Unexecuted instantiation: <char as phf_shared::FmtConst>::fmt_const Unexecuted instantiation: <u8 as phf_shared::FmtConst>::fmt_const Unexecuted instantiation: <i8 as phf_shared::FmtConst>::fmt_const Unexecuted instantiation: <u16 as phf_shared::FmtConst>::fmt_const Unexecuted instantiation: <i16 as phf_shared::FmtConst>::fmt_const Unexecuted instantiation: <u32 as phf_shared::FmtConst>::fmt_const Unexecuted instantiation: <i32 as phf_shared::FmtConst>::fmt_const Unexecuted instantiation: <u64 as phf_shared::FmtConst>::fmt_const Unexecuted instantiation: <i64 as phf_shared::FmtConst>::fmt_const Unexecuted instantiation: <usize as phf_shared::FmtConst>::fmt_const Unexecuted instantiation: <isize as phf_shared::FmtConst>::fmt_const Unexecuted instantiation: <u128 as phf_shared::FmtConst>::fmt_const Unexecuted instantiation: <i128 as phf_shared::FmtConst>::fmt_const Unexecuted instantiation: <bool as phf_shared::FmtConst>::fmt_const |
141 | | } |
142 | | } |
143 | | ); |
144 | | |
145 | | delegate_debug!(str); |
146 | | delegate_debug!(char); |
147 | | delegate_debug!(u8); |
148 | | delegate_debug!(i8); |
149 | | delegate_debug!(u16); |
150 | | delegate_debug!(i16); |
151 | | delegate_debug!(u32); |
152 | | delegate_debug!(i32); |
153 | | delegate_debug!(u64); |
154 | | delegate_debug!(i64); |
155 | | delegate_debug!(usize); |
156 | | delegate_debug!(isize); |
157 | | delegate_debug!(u128); |
158 | | delegate_debug!(i128); |
159 | | delegate_debug!(bool); |
160 | | |
161 | | /// `impl PhfBorrow<T> for T` |
162 | | macro_rules! impl_reflexive( |
163 | | ($($t:ty),*) => ( |
164 | | $(impl PhfBorrow<$t> for $t { |
165 | 0 | fn borrow(&self) -> &$t { |
166 | 0 | self |
167 | 0 | } Unexecuted instantiation: <usize as phf_shared::PhfBorrow<usize>>::borrow Unexecuted instantiation: <isize as phf_shared::PhfBorrow<isize>>::borrow Unexecuted instantiation: <u128 as phf_shared::PhfBorrow<u128>>::borrow Unexecuted instantiation: <i128 as phf_shared::PhfBorrow<i128>>::borrow Unexecuted instantiation: <bool as phf_shared::PhfBorrow<bool>>::borrow Unexecuted instantiation: <[u8] as phf_shared::PhfBorrow<[u8]>>::borrow Unexecuted instantiation: <str as phf_shared::PhfBorrow<str>>::borrow Unexecuted instantiation: <char as phf_shared::PhfBorrow<char>>::borrow Unexecuted instantiation: <u8 as phf_shared::PhfBorrow<u8>>::borrow Unexecuted instantiation: <i8 as phf_shared::PhfBorrow<i8>>::borrow Unexecuted instantiation: <u16 as phf_shared::PhfBorrow<u16>>::borrow Unexecuted instantiation: <i16 as phf_shared::PhfBorrow<i16>>::borrow Unexecuted instantiation: <u32 as phf_shared::PhfBorrow<u32>>::borrow Unexecuted instantiation: <i32 as phf_shared::PhfBorrow<i32>>::borrow Unexecuted instantiation: <u64 as phf_shared::PhfBorrow<u64>>::borrow Unexecuted instantiation: <i64 as phf_shared::PhfBorrow<i64>>::borrow |
168 | | })* |
169 | | ) |
170 | | ); |
171 | | |
172 | | impl_reflexive!( |
173 | | str, |
174 | | char, |
175 | | u8, |
176 | | i8, |
177 | | u16, |
178 | | i16, |
179 | | u32, |
180 | | i32, |
181 | | u64, |
182 | | i64, |
183 | | usize, |
184 | | isize, |
185 | | u128, |
186 | | i128, |
187 | | bool, |
188 | | [u8] |
189 | | ); |
190 | | |
191 | | #[cfg(feature = "std")] |
192 | | impl PhfBorrow<str> for String { |
193 | 0 | fn borrow(&self) -> &str { |
194 | 0 | self |
195 | 0 | } |
196 | | } |
197 | | |
198 | | #[cfg(feature = "std")] |
199 | | impl PhfBorrow<[u8]> for Vec<u8> { |
200 | 0 | fn borrow(&self) -> &[u8] { |
201 | 0 | self |
202 | 0 | } |
203 | | } |
204 | | |
205 | | #[cfg(feature = "std")] |
206 | | delegate_debug!(String); |
207 | | |
208 | | #[cfg(feature = "std")] |
209 | | impl PhfHash for String { |
210 | | #[inline] |
211 | 0 | fn phf_hash<H: Hasher>(&self, state: &mut H) { |
212 | 0 | (**self).phf_hash(state) |
213 | 0 | } |
214 | | } |
215 | | |
216 | | #[cfg(feature = "std")] |
217 | | impl PhfHash for Vec<u8> { |
218 | | #[inline] |
219 | 0 | fn phf_hash<H: Hasher>(&self, state: &mut H) { |
220 | 0 | (**self).phf_hash(state) |
221 | 0 | } |
222 | | } |
223 | | |
224 | | impl<'a, T: 'a + PhfHash + ?Sized> PhfHash for &'a T { |
225 | 0 | fn phf_hash<H: Hasher>(&self, state: &mut H) { |
226 | 0 | (*self).phf_hash(state) |
227 | 0 | } |
228 | | } |
229 | | |
230 | | impl<'a, T: 'a + FmtConst + ?Sized> FmtConst for &'a T { |
231 | 0 | fn fmt_const(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
232 | 0 | (*self).fmt_const(f) |
233 | 0 | } |
234 | | } |
235 | | |
236 | | impl<'a> PhfBorrow<str> for &'a str { |
237 | 0 | fn borrow(&self) -> &str { |
238 | 0 | self |
239 | 0 | } |
240 | | } |
241 | | |
242 | | impl<'a> PhfBorrow<[u8]> for &'a [u8] { |
243 | 0 | fn borrow(&self) -> &[u8] { |
244 | 0 | self |
245 | 0 | } |
246 | | } |
247 | | |
248 | | impl<'a, const N: usize> PhfBorrow<[u8; N]> for &'a [u8; N] { |
249 | 0 | fn borrow(&self) -> &[u8; N] { |
250 | 0 | self |
251 | 0 | } |
252 | | } |
253 | | |
254 | | impl PhfHash for str { |
255 | | #[inline] |
256 | 0 | fn phf_hash<H: Hasher>(&self, state: &mut H) { |
257 | 0 | self.as_bytes().phf_hash(state) |
258 | 0 | } Unexecuted instantiation: <str as phf_shared::PhfHash>::phf_hash::<siphasher::sip128::SipHasher13> Unexecuted instantiation: <str as phf_shared::PhfHash>::phf_hash::<_> |
259 | | } |
260 | | |
261 | | impl PhfHash for [u8] { |
262 | | #[inline] |
263 | 0 | fn phf_hash<H: Hasher>(&self, state: &mut H) { |
264 | 0 | state.write(self); |
265 | 0 | } Unexecuted instantiation: <[u8] as phf_shared::PhfHash>::phf_hash::<siphasher::sip128::SipHasher13> Unexecuted instantiation: <[u8] as phf_shared::PhfHash>::phf_hash::<_> |
266 | | } |
267 | | |
268 | | impl FmtConst for [u8] { |
269 | | #[inline] |
270 | 0 | fn fmt_const(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
271 | | // slices need a leading reference |
272 | 0 | write!(f, "&{:?}", self) |
273 | 0 | } |
274 | | } |
275 | | |
276 | | #[cfg(feature = "unicase")] |
277 | | impl<S> PhfHash for unicase::UniCase<S> |
278 | | where |
279 | | unicase::UniCase<S>: Hash, |
280 | | { |
281 | | #[inline] |
282 | | fn phf_hash<H: Hasher>(&self, state: &mut H) { |
283 | | self.hash(state) |
284 | | } |
285 | | } |
286 | | |
287 | | #[cfg(feature = "unicase")] |
288 | | impl<S> FmtConst for unicase::UniCase<S> |
289 | | where |
290 | | S: AsRef<str>, |
291 | | { |
292 | | fn fmt_const(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
293 | | if self.is_ascii() { |
294 | | f.write_str("UniCase::ascii(")?; |
295 | | } else { |
296 | | f.write_str("UniCase::unicode(")?; |
297 | | } |
298 | | |
299 | | self.as_ref().fmt_const(f)?; |
300 | | f.write_str(")") |
301 | | } |
302 | | } |
303 | | |
304 | | #[cfg(feature = "unicase")] |
305 | | impl<'b, 'a: 'b, S: ?Sized + 'a> PhfBorrow<unicase::UniCase<&'b S>> for unicase::UniCase<&'a S> { |
306 | | fn borrow(&self) -> &unicase::UniCase<&'b S> { |
307 | | self |
308 | | } |
309 | | } |
310 | | |
311 | | #[cfg(feature = "uncased")] |
312 | | impl PhfHash for uncased::UncasedStr { |
313 | | #[inline] |
314 | | fn phf_hash<H: Hasher>(&self, state: &mut H) { |
315 | | self.hash(state) |
316 | | } |
317 | | } |
318 | | |
319 | | #[cfg(feature = "uncased")] |
320 | | impl FmtConst for uncased::UncasedStr { |
321 | | fn fmt_const(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
322 | | f.write_str("UncasedStr::new(")?; |
323 | | self.as_str().fmt_const(f)?; |
324 | | f.write_str(")") |
325 | | } |
326 | | } |
327 | | |
328 | | #[cfg(feature = "uncased")] |
329 | | impl PhfBorrow<uncased::UncasedStr> for &uncased::UncasedStr { |
330 | | fn borrow(&self) -> &uncased::UncasedStr { |
331 | | self |
332 | | } |
333 | | } |
334 | | |
335 | | macro_rules! sip_impl ( |
336 | | (le $t:ty) => ( |
337 | | impl PhfHash for $t { |
338 | | #[inline] |
339 | 0 | fn phf_hash<H: Hasher>(&self, state: &mut H) { |
340 | 0 | self.to_le().hash(state); |
341 | 0 | } Unexecuted instantiation: <u16 as phf_shared::PhfHash>::phf_hash::<_> Unexecuted instantiation: <i16 as phf_shared::PhfHash>::phf_hash::<_> Unexecuted instantiation: <u32 as phf_shared::PhfHash>::phf_hash::<_> Unexecuted instantiation: <i32 as phf_shared::PhfHash>::phf_hash::<_> Unexecuted instantiation: <u64 as phf_shared::PhfHash>::phf_hash::<_> Unexecuted instantiation: <i64 as phf_shared::PhfHash>::phf_hash::<_> Unexecuted instantiation: <usize as phf_shared::PhfHash>::phf_hash::<_> Unexecuted instantiation: <isize as phf_shared::PhfHash>::phf_hash::<_> Unexecuted instantiation: <u128 as phf_shared::PhfHash>::phf_hash::<_> Unexecuted instantiation: <i128 as phf_shared::PhfHash>::phf_hash::<_> |
342 | | } |
343 | | ); |
344 | | ($t:ty) => ( |
345 | | impl PhfHash for $t { |
346 | | #[inline] |
347 | 0 | fn phf_hash<H: Hasher>(&self, state: &mut H) { |
348 | 0 | self.hash(state); |
349 | 0 | } Unexecuted instantiation: <u8 as phf_shared::PhfHash>::phf_hash::<_> Unexecuted instantiation: <i8 as phf_shared::PhfHash>::phf_hash::<_> Unexecuted instantiation: <bool as phf_shared::PhfHash>::phf_hash::<_> |
350 | | } |
351 | | ) |
352 | | ); |
353 | | |
354 | | sip_impl!(u8); |
355 | | sip_impl!(i8); |
356 | | sip_impl!(le u16); |
357 | | sip_impl!(le i16); |
358 | | sip_impl!(le u32); |
359 | | sip_impl!(le i32); |
360 | | sip_impl!(le u64); |
361 | | sip_impl!(le i64); |
362 | | sip_impl!(le usize); |
363 | | sip_impl!(le isize); |
364 | | sip_impl!(le u128); |
365 | | sip_impl!(le i128); |
366 | | sip_impl!(bool); |
367 | | |
368 | | impl PhfHash for char { |
369 | | #[inline] |
370 | 0 | fn phf_hash<H: Hasher>(&self, state: &mut H) { |
371 | 0 | (*self as u32).phf_hash(state) |
372 | 0 | } |
373 | | } |
374 | | |
375 | | // minimize duplicated code since formatting drags in quite a bit |
376 | 0 | fn fmt_array<T: core::fmt::Debug>(array: &[T], f: &mut fmt::Formatter<'_>) -> fmt::Result { |
377 | 0 | write!(f, "{:?}", array) |
378 | 0 | } |
379 | | |
380 | | macro_rules! array_impl ( |
381 | | ($t:ty) => ( |
382 | | impl<const N: usize> PhfHash for [$t; N] { |
383 | | #[inline] |
384 | 0 | fn phf_hash<H: Hasher>(&self, state: &mut H) { |
385 | 0 | for v in &self[..] { |
386 | 0 | v.phf_hash(state); |
387 | 0 | } |
388 | 0 | } Unexecuted instantiation: <[u16; _] as phf_shared::PhfHash>::phf_hash::<_> Unexecuted instantiation: <[i16; _] as phf_shared::PhfHash>::phf_hash::<_> Unexecuted instantiation: <[u32; _] as phf_shared::PhfHash>::phf_hash::<_> Unexecuted instantiation: <[i32; _] as phf_shared::PhfHash>::phf_hash::<_> Unexecuted instantiation: <[u64; _] as phf_shared::PhfHash>::phf_hash::<_> Unexecuted instantiation: <[i64; _] as phf_shared::PhfHash>::phf_hash::<_> Unexecuted instantiation: <[usize; _] as phf_shared::PhfHash>::phf_hash::<_> Unexecuted instantiation: <[isize; _] as phf_shared::PhfHash>::phf_hash::<_> Unexecuted instantiation: <[u128; _] as phf_shared::PhfHash>::phf_hash::<_> Unexecuted instantiation: <[i128; _] as phf_shared::PhfHash>::phf_hash::<_> Unexecuted instantiation: <[bool; _] as phf_shared::PhfHash>::phf_hash::<_> Unexecuted instantiation: <[char; _] as phf_shared::PhfHash>::phf_hash::<_> Unexecuted instantiation: <[u8; _] as phf_shared::PhfHash>::phf_hash::<_> Unexecuted instantiation: <[i8; _] as phf_shared::PhfHash>::phf_hash::<_> |
389 | | } |
390 | | |
391 | | impl<const N: usize> FmtConst for [$t; N] { |
392 | 0 | fn fmt_const(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
393 | 0 | fmt_array(self, f) |
394 | 0 | } Unexecuted instantiation: <[u16; _] as phf_shared::FmtConst>::fmt_const Unexecuted instantiation: <[i16; _] as phf_shared::FmtConst>::fmt_const Unexecuted instantiation: <[u32; _] as phf_shared::FmtConst>::fmt_const Unexecuted instantiation: <[i32; _] as phf_shared::FmtConst>::fmt_const Unexecuted instantiation: <[u64; _] as phf_shared::FmtConst>::fmt_const Unexecuted instantiation: <[i64; _] as phf_shared::FmtConst>::fmt_const Unexecuted instantiation: <[usize; _] as phf_shared::FmtConst>::fmt_const Unexecuted instantiation: <[isize; _] as phf_shared::FmtConst>::fmt_const Unexecuted instantiation: <[u128; _] as phf_shared::FmtConst>::fmt_const Unexecuted instantiation: <[i128; _] as phf_shared::FmtConst>::fmt_const Unexecuted instantiation: <[bool; _] as phf_shared::FmtConst>::fmt_const Unexecuted instantiation: <[char; _] as phf_shared::FmtConst>::fmt_const Unexecuted instantiation: <[u8; _] as phf_shared::FmtConst>::fmt_const Unexecuted instantiation: <[i8; _] as phf_shared::FmtConst>::fmt_const |
395 | | } |
396 | | |
397 | | impl<const N: usize> PhfBorrow<[$t]> for [$t; N] { |
398 | 0 | fn borrow(&self) -> &[$t] { |
399 | 0 | self |
400 | 0 | } Unexecuted instantiation: <[u16; _] as phf_shared::PhfBorrow<[u16]>>::borrow Unexecuted instantiation: <[i16; _] as phf_shared::PhfBorrow<[i16]>>::borrow Unexecuted instantiation: <[u32; _] as phf_shared::PhfBorrow<[u32]>>::borrow Unexecuted instantiation: <[i32; _] as phf_shared::PhfBorrow<[i32]>>::borrow Unexecuted instantiation: <[u64; _] as phf_shared::PhfBorrow<[u64]>>::borrow Unexecuted instantiation: <[i64; _] as phf_shared::PhfBorrow<[i64]>>::borrow Unexecuted instantiation: <[usize; _] as phf_shared::PhfBorrow<[usize]>>::borrow Unexecuted instantiation: <[isize; _] as phf_shared::PhfBorrow<[isize]>>::borrow Unexecuted instantiation: <[u128; _] as phf_shared::PhfBorrow<[u128]>>::borrow Unexecuted instantiation: <[i128; _] as phf_shared::PhfBorrow<[i128]>>::borrow Unexecuted instantiation: <[bool; _] as phf_shared::PhfBorrow<[bool]>>::borrow Unexecuted instantiation: <[char; _] as phf_shared::PhfBorrow<[char]>>::borrow Unexecuted instantiation: <[u8; _] as phf_shared::PhfBorrow<[u8]>>::borrow Unexecuted instantiation: <[i8; _] as phf_shared::PhfBorrow<[i8]>>::borrow |
401 | | } |
402 | | ) |
403 | | ); |
404 | | |
405 | | array_impl!(u8); |
406 | | array_impl!(i8); |
407 | | array_impl!(u16); |
408 | | array_impl!(i16); |
409 | | array_impl!(u32); |
410 | | array_impl!(i32); |
411 | | array_impl!(u64); |
412 | | array_impl!(i64); |
413 | | array_impl!(usize); |
414 | | array_impl!(isize); |
415 | | array_impl!(u128); |
416 | | array_impl!(i128); |
417 | | array_impl!(bool); |
418 | | array_impl!(char); |
419 | | |
420 | | macro_rules! slice_impl ( |
421 | | ($t:ty) => { |
422 | | impl PhfHash for [$t] { |
423 | | #[inline] |
424 | 0 | fn phf_hash<H: Hasher>(&self, state: &mut H) { |
425 | 0 | for v in self { |
426 | 0 | v.phf_hash(state); |
427 | 0 | } |
428 | 0 | } Unexecuted instantiation: <[i8] as phf_shared::PhfHash>::phf_hash::<_> Unexecuted instantiation: <[u16] as phf_shared::PhfHash>::phf_hash::<_> Unexecuted instantiation: <[i16] as phf_shared::PhfHash>::phf_hash::<_> Unexecuted instantiation: <[u32] as phf_shared::PhfHash>::phf_hash::<_> Unexecuted instantiation: <[i32] as phf_shared::PhfHash>::phf_hash::<_> Unexecuted instantiation: <[u64] as phf_shared::PhfHash>::phf_hash::<_> Unexecuted instantiation: <[i64] as phf_shared::PhfHash>::phf_hash::<_> Unexecuted instantiation: <[usize] as phf_shared::PhfHash>::phf_hash::<_> Unexecuted instantiation: <[isize] as phf_shared::PhfHash>::phf_hash::<_> Unexecuted instantiation: <[u128] as phf_shared::PhfHash>::phf_hash::<_> Unexecuted instantiation: <[i128] as phf_shared::PhfHash>::phf_hash::<_> Unexecuted instantiation: <[bool] as phf_shared::PhfHash>::phf_hash::<_> Unexecuted instantiation: <[char] as phf_shared::PhfHash>::phf_hash::<_> |
429 | | } |
430 | | }; |
431 | | ); |
432 | | |
433 | | slice_impl!(i8); |
434 | | slice_impl!(u16); |
435 | | slice_impl!(i16); |
436 | | slice_impl!(u32); |
437 | | slice_impl!(i32); |
438 | | slice_impl!(u64); |
439 | | slice_impl!(i64); |
440 | | slice_impl!(usize); |
441 | | slice_impl!(isize); |
442 | | slice_impl!(u128); |
443 | | slice_impl!(i128); |
444 | | slice_impl!(bool); |
445 | | slice_impl!(char); |