Trait alloc::sync::ArcEqIdent
1.0.0 · source · trait ArcEqIdent<T: ?Sized + PartialEq> {
// Required methods
fn eq(&self, other: &Arc<T>) -> bool;
fn ne(&self, other: &Arc<T>) -> bool;
}
Required Methods§
Implementors§
impl<T: ?Sized + PartialEq> ArcEqIdent<T> for Arc<T>
impl<T: ?Sized + MarkerEq> ArcEqIdent<T> for Arc<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 Arc
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 Arc
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.