Trait alloc::rc::RcEqIdent

1.0.0 · source ·
trait RcEqIdent<T: ?Sized + PartialEq> {
    // Required methods
    fn eq(&self, other: &Rc<T>) -> bool;
    fn ne(&self, other: &Rc<T>) -> bool;
}

Required Methods§

source

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

source

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

Implementors§

source§

impl<T: ?Sized + PartialEq> RcEqIdent<T> for Rc<T>

source§

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

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