workspace: move crates under crates
This commit is contained in:
parent
0016bc8cf0
commit
6393fdf3c0
354 changed files with 102 additions and 102 deletions
37
crates/utils/src/rc_eq.rs
Normal file
37
crates/utils/src/rc_eq.rs
Normal 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
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue