1
0
Fork 0
forked from wry/wry

workspace: move crates under crates

This commit is contained in:
kossLAN 2026-05-29 18:55:59 -04:00
parent 0016bc8cf0
commit 6393fdf3c0
No known key found for this signature in database
354 changed files with 102 additions and 102 deletions

37
crates/utils/src/rc_eq.rs Normal file
View file

@ -0,0 +1,37 @@
use std::{
ops::Deref,
rc::{Rc, Weak},
};
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 fn rc_weak_eq<T: ?Sized>(a: &Rc<T>, b: &Weak<T>) -> bool {
Rc::as_ptr(a) as *const u8 == b.as_ptr() as *const u8
}
#[derive(Default)]
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
}
}