rspace_traits/impls/
impl_store.rs

1/*
2    Appellation: impl_store <module>
3    Created At: 2025.12.26:19:48:49
4    Contrib: @FL03
5*/
6#[cfg(all(feature = "alloc", feature = "nightly"))]
7mod impl_alloc {
8    use crate::store::*;
9    use alloc::allocator::Allocator;
10    use alloc::collections::btree_map::{self, BTreeMap};
11    use alloc::vec::Vec;
12
13    impl<'a, K, V, A> StoreEntry<'a> for btree_map::Entry<'a, K, V, A>
14    where
15        A: Allocator,
16    {
17        type Key = K;
18        type Value = V;
19    }
20
21    impl<K, V, A> Store<K, V> for BTreeMap<K, V, A>
22    where
23        A: Allocator,
24    {
25        type Entry<'a>
26            = btree_map::Entry<'a, K, V, A>
27        where
28            Self: 'a;
29    }
30
31    impl<T, A> RawStore<usize, T> for Vec<T, A> where A: Allocator {}
32}
33
34#[cfg(all(feature = "alloc", not(feature = "nightly")))]
35mod impl_alloc {
36    use crate::store::*;
37    use alloc::collections::btree_map::{self, BTreeMap};
38
39    impl<'a, K, V> StoreEntry<'a> for btree_map::Entry<'a, K, V> {
40        type Key = K;
41        type Value = V;
42    }
43
44    impl<K, V> RawStore<K, V> for BTreeMap<K, V> {}
45
46    impl<K, V> Store<K, V> for BTreeMap<K, V> {
47        type Entry<'a>
48            = btree_map::Entry<'a, K, V>
49        where
50            Self: 'a;
51    }
52
53    impl<T> RawStore<usize, T> for Vec<T> {}
54}
55
56#[cfg(feature = "hashbrown")]
57mod impl_hashbrown {
58    use crate::store::*;
59    use hashbrown::hash_map::{self, HashMap};
60
61    impl<'a, K, V, S> StoreEntry<'a> for hash_map::Entry<'a, K, V, S> {
62        type Key = K;
63        type Value = V;
64    }
65
66    impl<K, V, S> RawStore<K, V> for HashMap<K, V, S> {}
67
68    impl<K, V, S> Store<K, V> for HashMap<K, V, S> {
69        type Entry<'a>
70            = hash_map::Entry<'a, K, V, S>
71        where
72            Self: 'a;
73    }
74}
75
76#[cfg(feature = "std")]
77mod impl_std {
78    use crate::store::*;
79    use std::collections::hash_map::{self, HashMap};
80
81    impl<'a, K, V> StoreEntry<'a> for hash_map::Entry<'a, K, V> {
82        type Key = K;
83        type Value = V;
84    }
85
86    impl<K, V> RawStore<K, V> for HashMap<K, V> {}
87
88    impl<K, V> Store<K, V> for HashMap<K, V> {
89        type Entry<'a>
90            = hash_map::Entry<'a, K, V>
91        where
92            Self: 'a;
93    }
94}