This commit is contained in:
Ralf Jung
2026-04-19 12:35:25 +02:00
parent ed395bba8d
commit 8aefb076b9
@@ -96,10 +96,7 @@ fn get_or<E>(&self, k: K, vacant: impl FnOnce() -> Result<V, E>) -> Result<&V, E
/// Read-only lookup (avoid read-acquiring the RefCell).
fn get(&self, k: K) -> Option<&V> {
let val: *const V = match self.0.borrow().get(&k) {
Some(v) => &**v,
None => return None,
};
let val: *const V = &**self.0.borrow().get(&k)?;
// This is safe because `val` points into a `Box`, that we know will not move and
// will also not be dropped as long as the shared reference `self` is live.
unsafe { Some(&*val) }