mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-23 16:21: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 location = self.nodes.location(key, hash)?;
|
||||
Some(unsafe {
|
||||
self.nodes
|
||||
.location(key, hash)
|
||||
.and_then(|location| self.nodes.node_at(location).key_value_ref())
|
||||
.node_at_unchecked(location)
|
||||
.key_value_ref_unchecked()
|
||||
})
|
||||
}
|
||||
|
||||
/// 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)> {
|
||||
if self.has_value() {
|
||||
Some(unsafe { (self.key.assume_init_ref(), self.value.assume_init_ref()) })
|
||||
} else {
|
||||
None
|
||||
}
|
||||
pub(crate) unsafe fn key_value_ref_unchecked(&self) -> (&K, &V) {
|
||||
(self.key.assume_init_ref(), self.value.assume_init_ref())
|
||||
}
|
||||
|
||||
pub(crate) fn key_value_mut(&mut self) -> Option<(&K, &mut V)> {
|
||||
|
|
Loading…
Reference in a new issue