Skip to main content

stable_map/
eq.rs

1#[cfg(test)]
2mod tests;
3
4use {
5    crate::StableMap,
6    core::hash::{BuildHasher, Hash},
7};
8
9impl<K, V, S> Eq for StableMap<K, V, S>
10where
11    K: Eq + Hash,
12    V: Eq,
13    S: BuildHasher,
14{
15}
16
17impl<K, V, S> PartialEq for StableMap<K, V, S>
18where
19    K: Eq + Hash,
20    V: PartialEq,
21    S: BuildHasher,
22{
23    fn eq(&self, other: &Self) -> bool {
24        if self.len() != other.len() {
25            return false;
26        }
27        for (k, v) in self {
28            if other.get(k) != Some(v) {
29                return false;
30            }
31        }
32        true
33    }
34}