identity_core/common/
key_comparable.rs1pub trait KeyComparable {
6 type Key: PartialEq + ?Sized;
8
9 fn key(&self) -> &Self::Key;
11}
12
13macro_rules! impl_key_comparable {
18 ($($t:ty)*) => ($(
19 impl KeyComparable for $t {
20 type Key = $t;
21 #[inline]
22 fn key(&self) -> &Self::Key { self }
23 }
24 )*)
25}
26
27impl_key_comparable! {
28 str bool char usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64
29}
30
31impl KeyComparable for &str {
32 type Key = str;
33
34 fn key(&self) -> &Self::Key {
35 self
36 }
37}
38
39impl KeyComparable for String {
40 type Key = str;
41
42 fn key(&self) -> &Self::Key {
43 self
44 }
45}