1
0
Fork 0
forked from wry/wry

tree: implement pointer constraints

This commit is contained in:
Julian Orth 2022-07-21 20:16:22 +02:00
parent d4c4497043
commit 38d1267ec9
19 changed files with 707 additions and 4 deletions

View file

@ -42,6 +42,10 @@ impl<K: Eq, V, const N: usize> SmallMap<K, V, N> {
}
}
pub fn contains(&self, k: &K) -> bool {
unsafe { self.m.get().deref().contains(k) }
}
pub fn len(&self) -> usize {
unsafe { self.m.get().deref().len() }
}
@ -158,6 +162,15 @@ impl<K: Eq, V, const N: usize> SmallMapMut<K, V, N> {
self.m.len()
}
pub fn contains(&self, k: &K) -> bool {
for (ek, _) in &self.m {
if ek == k {
return true;
}
}
false
}
pub fn insert(&mut self, k: K, v: V) -> Option<V> {
for (ek, ev) in &mut self.m {
if ek == &k {