Skip to main content

json_gettext/key_copy/
mod.rs

1use std::collections::HashMap;
2
3mod keys;
4
5// Only trait implementations for `Key` live here; nothing needs to be re-exported.
6#[cfg(feature = "rocket")]
7mod rocket_feature;
8
9pub use keys::*;
10
11use crate::{IntoKey, LookupKey};
12
13impl LookupKey for Key {
14    #[inline]
15    fn lookup<'m, V>(&self, map: &'m HashMap<Key, V>) -> Option<&'m V> {
16        map.get(self)
17    }
18}
19
20impl LookupKey for &Key {
21    #[inline]
22    fn lookup<'m, V>(&self, map: &'m HashMap<Key, V>) -> Option<&'m V> {
23        map.get(*self)
24    }
25}
26
27impl IntoKey for Key {
28    #[inline]
29    fn into_key(self) -> Key {
30        self
31    }
32}
33
34impl IntoKey for &Key {
35    #[inline]
36    fn into_key(self) -> Key {
37        *self
38    }
39}