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§

source

fn eq(&self, other: &Arc<T>) -> bool

source

fn ne(&self, other: &Arc<T>) -> bool

Implementors§

source§

impl<T: ?Sized + PartialEq> ArcEqIdent<T> for Arc<T>

source§

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 Arcs 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 &Ts.

We can only do this when T: Eq as a PartialEq might be deliberately irreflexive.