all: split reusable components into workspace crates
This commit is contained in:
parent
2a079ed800
commit
657e7ce2f7
225 changed files with 7422 additions and 17602 deletions
|
|
@ -1,37 +0,0 @@
|
|||
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