mirror of
https://github.com/italicsjenga/agb.git
synced 2025-01-09 16:41:33 +11:00
Key value ref unchecked
This commit is contained in:
parent
dc8589479e
commit
917163f88b
|
@ -350,9 +350,12 @@ where
|
||||||
{
|
{
|
||||||
let hash = self.hash(key);
|
let hash = self.hash(key);
|
||||||
|
|
||||||
self.nodes
|
let location = self.nodes.location(key, hash)?;
|
||||||
.location(key, hash)
|
Some(unsafe {
|
||||||
.and_then(|location| self.nodes.node_at(location).key_value_ref())
|
self.nodes
|
||||||
|
.node_at_unchecked(location)
|
||||||
|
.key_value_ref_unchecked()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a reference to the value corresponding to the key. Returns [`None`] if there is
|
/// Returns a reference to the value corresponding to the key. Returns [`None`] if there is
|
||||||
|
|
|
@ -66,12 +66,8 @@ impl<K, V> Node<K, V> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn key_value_ref(&self) -> Option<(&K, &V)> {
|
pub(crate) unsafe fn key_value_ref_unchecked(&self) -> (&K, &V) {
|
||||||
if self.has_value() {
|
(self.key.assume_init_ref(), self.value.assume_init_ref())
|
||||||
Some(unsafe { (self.key.assume_init_ref(), self.value.assume_init_ref()) })
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn key_value_mut(&mut self) -> Option<(&K, &mut V)> {
|
pub(crate) fn key_value_mut(&mut self) -> Option<(&K, &mut V)> {
|
||||||
|
|
Loading…
Reference in a new issue