trait RcEqIdent<T: ?Sized + PartialEq> {
// Required methods
fn eq(&self, other: &Rc<T>) -> bool;
fn ne(&self, other: &Rc<T>) -> bool;
}
Required Methods§
Implementors§
impl<T: ?Sized + PartialEq> RcEqIdent<T> for Rc<T>
impl<T: ?Sized + MarkerEq> RcEqIdent<T> for Rc<T>
We’re doing this specialization here, and not as a more general optimization on &T
, because it
would otherwise add a cost to all equality checks on refs. We assume that Rc
s are used to
store large values, that are slow to clone, but also heavy to check for equality, causing this
cost to pay off more easily. It’s also more likely to have two Rc
clones, that point to
the same value, than two &T
s.
We can only do this when T: Eq
as a PartialEq
might be deliberately irreflexive.