use std::{ ops::Deref, rc::{Rc, Weak}, }; pub fn rc_eq(a: &Rc, b: &Rc) -> bool { Rc::as_ptr(a) as *const u8 == Rc::as_ptr(b) as *const u8 } pub fn rc_weak_eq(a: &Rc, b: &Weak) -> bool { Rc::as_ptr(a) as *const u8 == b.as_ptr() as *const u8 } #[derive(Default)] pub struct RcEq(pub Rc); impl Clone for RcEq { fn clone(&self) -> Self { Self(self.0.clone()) } } impl PartialEq for RcEq { fn eq(&self, other: &Self) -> bool { rc_eq(&self.0, &other.0) } } impl Eq for RcEq {} impl Deref for RcEq { type Target = T; fn deref(&self) -> &Self::Target { &self.0 } }