std::cmp::PartialEq
Trait std::cmp::PartialEq
#[lang = "eq"] pub trait PartialEq<Rhs = Self> where Rhs: ?Sized, { fn eq(&self, other: &Rhs) -> bool; fn ne(&self, other: &Rhs) -> bool { ... } }
Trait for equality comparisons which are partial equivalence relations.
This trait allows for partial equality, for types that do not have a full equivalence relation. For example, in floating point numbers NaN != NaN
, so floating point types implement PartialEq
but not Eq
.
Formally, the equality must be (for all a
, b
and c
):
- symmetric:
a == b
impliesb == a
; and - transitive:
a == b
andb == c
impliesa == c
. 登录查看完整内容