Trait core::cmp::Eq 1.0.0[−][src]
pub trait Eq: PartialEq<Self> { }
Trait for equality comparisons which are equivalence relations.
This means, that in addition to a == b and a != b being strict inverses, the equality must
be (for all a, b and c):
- reflexive:
a == a; - symmetric:
a == bimpliesb == a; and - transitive:
a == bandb == cimpliesa == c.
This property cannot be checked by the compiler, and therefore Eq implies
PartialEq, and has no extra methods.
Derivable
This trait can be used with #[derive]. When derived, because Eq has
no extra methods, it is only informing the compiler that this is an
equivalence relation rather than a partial equivalence relation. Note that
the derive strategy requires all fields are Eq, which isn’t
always desired.
How can I implement Eq?
If you cannot use the derive strategy, specify that your type implements
Eq, which has no methods:
enum BookFormat { Paperback, Hardback, Ebook } struct Book { isbn: i32, format: BookFormat, } impl PartialEq for Book { fn eq(&self, other: &Self) -> bool { self.isbn == other.isbn } } impl Eq for Book {}Run
Implementors
impl Eq for ![src]
impl Eq for ()[src]
impl Eq for Infallible1.34.0[src]
impl Eq for FpCategory[src]
impl Eq for IntErrorKind[src]
impl Eq for SearchStep[src]
impl Eq for core::sync::atomic::Ordering[src]
impl Eq for core::cmp::Ordering[src]
impl Eq for AllocError[src]
impl Eq for Layout1.28.0[src]
impl Eq for LayoutError1.50.0[src]
impl Eq for TypeId[src]
impl Eq for CpuidResult1.27.0[src]
This is supported on x86 or x86-64 only.
impl Eq for CharTryFromError1.34.0[src]
impl Eq for DecodeUtf16Error1.9.0[src]
impl Eq for ParseCharError1.20.0[src]
impl Eq for Error[src]
impl Eq for PhantomPinned1.33.0[src]
impl Eq for NonZeroI81.34.0[src]
impl Eq for NonZeroI161.34.0[src]
impl Eq for NonZeroI321.34.0[src]
impl Eq for NonZeroI641.34.0[src]
impl Eq for NonZeroI1281.34.0[src]
impl Eq for NonZeroIsize1.34.0[src]
impl Eq for NonZeroU81.28.0[src]
impl Eq for NonZeroU161.28.0[src]
impl Eq for NonZeroU321.28.0[src]
impl Eq for NonZeroU641.28.0[src]
impl Eq for NonZeroU1281.28.0[src]
impl Eq for NonZeroUsize1.28.0[src]
impl Eq for ParseFloatError[src]
impl Eq for ParseIntError[src]
impl Eq for TryFromIntError1.34.0[src]
impl Eq for RangeFull[src]
impl Eq for NoneError[src]
impl Eq for ParseBoolError[src]
impl Eq for Utf8Error[src]
impl Eq for Duration1.3.0[src]
impl Eq for bool[src]
impl Eq for char[src]
impl Eq for i8[src]
impl Eq for i16[src]
impl Eq for i32[src]
impl Eq for i64[src]
impl Eq for i128[src]
impl Eq for isize[src]
impl Eq for str[src]
impl Eq for u8[src]
impl Eq for u16[src]
impl Eq for u32[src]
impl Eq for u64[src]
impl Eq for u128[src]
impl Eq for usize[src]
impl<'a> Eq for Location<'a>1.10.0[src]
impl<'a> Eq for Utf8LossyChunk<'a>[src]
impl<A> Eq for (A,) where
A: Eq + ?Sized, [src]
A: Eq + ?Sized,
impl<A: Eq, B> Eq for (A, B) where
B: Eq + ?Sized, [src]
B: Eq + ?Sized,
impl<A: Eq, B: Eq, C> Eq for (A, B, C) where
C: Eq + ?Sized, [src]
C: Eq + ?Sized,
impl<A: Eq, B: Eq, C: Eq, D> Eq for (A, B, C, D) where
D: Eq + ?Sized, [src]
D: Eq + ?Sized,
impl<A: Eq, B: Eq, C: Eq, D: Eq, E> Eq for (A, B, C, D, E) where
E: Eq + ?Sized, [src]
E: Eq + ?Sized,
impl<A: Eq, B: Eq, C: Eq, D: Eq, E: Eq, F> Eq for (A, B, C, D, E, F) where
F: Eq + ?Sized, [src]
F: Eq + ?Sized,
impl<A: Eq, B: Eq, C: Eq, D: Eq, E: Eq, F: Eq, G> Eq for (A, B, C, D, E, F, G) where
G: Eq + ?Sized, [src]
G: Eq + ?Sized,
impl<A: Eq, B: Eq, C: Eq, D: Eq, E: Eq, F: Eq, G: Eq, H> Eq for (A, B, C, D, E, F, G, H) where
H: Eq + ?Sized, [src]
H: Eq + ?Sized,
impl<A: Eq, B: Eq, C: Eq, D: Eq, E: Eq, F: Eq, G: Eq, H: Eq, I> Eq for (A, B, C, D, E, F, G, H, I) where
I: Eq + ?Sized, [src]
I: Eq + ?Sized,
impl<A: Eq, B: Eq, C: Eq, D: Eq, E: Eq, F: Eq, G: Eq, H: Eq, I: Eq, J> Eq for (A, B, C, D, E, F, G, H, I, J) where
J: Eq + ?Sized, [src]
J: Eq + ?Sized,
impl<A: Eq, B: Eq, C: Eq, D: Eq, E: Eq, F: Eq, G: Eq, H: Eq, I: Eq, J: Eq, K> Eq for (A, B, C, D, E, F, G, H, I, J, K) where
K: Eq + ?Sized, [src]
K: Eq + ?Sized,
impl<A: Eq, B: Eq, C: Eq, D: Eq, E: Eq, F: Eq, G: Eq, H: Eq, I: Eq, J: Eq, K: Eq, L> Eq for (A, B, C, D, E, F, G, H, I, J, K, L) where
L: Eq + ?Sized, [src]
L: Eq + ?Sized,
impl<A: ?Sized> Eq for &A where
A: Eq, [src]
A: Eq,
impl<A: ?Sized> Eq for &mut A where
A: Eq, [src]
A: Eq,