1
0
Fork 0
forked from wry/wry

head-management: add infrastructure

This commit is contained in:
Julian Orth 2025-07-12 09:13:14 +02:00
parent 078c59d730
commit 8356dd5d5c
28 changed files with 1791 additions and 21 deletions

View file

@ -66,6 +66,14 @@ impl<K: Eq + Hash, V> CopyHashMap<K, V> {
unsafe { self.map.get().deref().contains_key(k) }
}
pub fn not_contains<Q>(&self, k: &Q) -> bool
where
Q: Hash + Eq + ?Sized,
K: Borrow<Q>,
{
!self.contains(k)
}
pub fn lock(&self) -> Locked<'_, K, V> {
Locked {
source: self,

View file

@ -1,5 +1,29 @@
use std::rc::Rc;
use std::{ops::Deref, rc::Rc};
pub fn rc_eq<T: ?Sized>(a: &Rc<T>, b: &Rc<T>) -> bool {
Rc::as_ptr(a) as *const u8 == Rc::as_ptr(b) as *const u8
}
pub struct RcEq<T>(pub Rc<T>);
impl<T> Clone for RcEq<T> {
fn clone(&self) -> Self {
Self(self.0.clone())
}
}
impl<T> PartialEq for RcEq<T> {
fn eq(&self, other: &Self) -> bool {
rc_eq(&self.0, &other.0)
}
}
impl<T> Eq for RcEq<T> {}
impl<T> Deref for RcEq<T> {
type Target = T;
fn deref(&self) -> &Self::Target {
&self.0
}
}