stable_map/
index.rs

1#[cfg(test)]
2mod tests;
3
4use {
5    crate::StableMap,
6    core::{
7        hash::{BuildHasher, Hash},
8        ops::Index,
9    },
10    hashbrown::Equivalent,
11};
12
13impl<K, Q, V, S> Index<&Q> for StableMap<K, V, S>
14where
15    K: Eq + Hash,
16    Q: Hash + Equivalent<K> + ?Sized,
17    S: BuildHasher,
18{
19    type Output = V;
20
21    fn index(&self, index: &Q) -> &Self::Output {
22        self.get(index).expect("index out of bounds")
23    }
24}