Trait std::cmp::PartialEq[src]

pub trait PartialEq {
    fn eq(&self, other: &Self) -> bool;

    fn ne(&self, other: &Self) -> bool { ... }
}

Trait for values that can be compared for equality and inequality.

This trait allows for partial equality, for types that do not have an equivalence relation. For example, in floating point numbers NaN != NaN, so floating point types implement PartialEq but not Eq.

PartialEq only requires the eq method to be implemented; ne is defined in terms of it by default. Any manual implementation of ne must respect the rule that eq is a strict inverse of ne; that is, !(a == b) if and only if a != b.

Eventually, this will be implemented by default for types that implement Eq.

Required Methods

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.

Provided Methods

fn ne(&self, other: &Self) -> bool

This method tests for !=.

Implementors