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 == b
impliesb == a
; and - transitive:
a == b
andb == c
impliesa == 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 derive
d, 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: &Book) -> bool { self.isbn == other.isbn } } impl Eq for Book {}Run
Implementors
impl Eq for ParseFloatError
impl Eq for NonZeroU8
impl Eq for NonZeroU16
impl Eq for NonZeroU32
impl Eq for NonZeroU64
impl Eq for NonZeroU128
impl Eq for NonZeroUsize
impl<T: Eq> Eq for Wrapping<T>
impl Eq for FpCategory
impl Eq for ParseIntError
impl<T> Eq for Discriminant<T>
impl<T: Eq> Eq for ManuallyDrop<T>
impl<T: ?Sized> Eq for *const T
impl<T: ?Sized> Eq for *mut T
impl<Ret> Eq for fn() -> Ret
impl<Ret> Eq for extern "C" fn() -> Ret
impl<Ret> Eq for unsafe fn() -> Ret
impl<Ret> Eq for unsafe extern "C" fn() -> Ret
impl<Ret, A> Eq for fn(_: A) -> Ret
impl<Ret, A> Eq for extern "C" fn(_: A) -> Ret
impl<Ret, A> Eq for extern "C" fn(_: A, ...) -> Ret
impl<Ret, A> Eq for unsafe fn(_: A) -> Ret
impl<Ret, A> Eq for unsafe extern "C" fn(_: A) -> Ret
impl<Ret, A> Eq for unsafe extern "C" fn(_: A, ...) -> Ret
impl<Ret, A, B> Eq for fn(_: A, _: B) -> Ret
impl<Ret, A, B> Eq for extern "C" fn(_: A, _: B) -> Ret
impl<Ret, A, B> Eq for extern "C" fn(_: A, _: B, ...) -> Ret
impl<Ret, A, B> Eq for unsafe fn(_: A, _: B) -> Ret
impl<Ret, A, B> Eq for unsafe extern "C" fn(_: A, _: B) -> Ret
impl<Ret, A, B> Eq for unsafe extern "C" fn(_: A, _: B, ...) -> Ret
impl<Ret, A, B, C> Eq for fn(_: A, _: B, _: C) -> Ret
impl<Ret, A, B, C> Eq for extern "C" fn(_: A, _: B, _: C) -> Ret
impl<Ret, A, B, C> Eq for extern "C" fn(_: A, _: B, _: C, ...) -> Ret
impl<Ret, A, B, C> Eq for unsafe fn(_: A, _: B, _: C) -> Ret
impl<Ret, A, B, C> Eq for unsafe extern "C" fn(_: A, _: B, _: C) -> Ret
impl<Ret, A, B, C> Eq for unsafe extern "C" fn(_: A, _: B, _: C, ...) -> Ret
impl<Ret, A, B, C, D> Eq for fn(_: A, _: B, _: C, _: D) -> Ret
impl<Ret, A, B, C, D> Eq for extern "C" fn(_: A, _: B, _: C, _: D) -> Ret
impl<Ret, A, B, C, D> Eq for extern "C" fn(_: A, _: B, _: C, _: D, ...) -> Ret
impl<Ret, A, B, C, D> Eq for unsafe fn(_: A, _: B, _: C, _: D) -> Ret
impl<Ret, A, B, C, D> Eq for unsafe extern "C" fn(_: A, _: B, _: C, _: D) -> Ret
impl<Ret, A, B, C, D> Eq for unsafe extern "C" fn(_: A, _: B, _: C, _: D, ...) -> Ret
impl<Ret, A, B, C, D, E> Eq for fn(_: A, _: B, _: C, _: D, _: E) -> Ret
impl<Ret, A, B, C, D, E> Eq for extern "C" fn(_: A, _: B, _: C, _: D, _: E) -> Ret
impl<Ret, A, B, C, D, E> Eq for extern "C" fn(_: A, _: B, _: C, _: D, _: E, ...) -> Ret
impl<Ret, A, B, C, D, E> Eq for unsafe fn(_: A, _: B, _: C, _: D, _: E) -> Ret
impl<Ret, A, B, C, D, E> Eq for unsafe extern "C" fn(_: A, _: B, _: C, _: D, _: E) -> Ret
impl<Ret, A, B, C, D, E> Eq for unsafe extern "C" fn(_: A, _: B, _: C, _: D, _: E, ...) -> Ret
impl<Ret, A, B, C, D, E, F> Eq for fn(_: A, _: B, _: C, _: D, _: E, _: F) -> Ret
impl<Ret, A, B, C, D, E, F> Eq for extern "C" fn(_: A, _: B, _: C, _: D, _: E, _: F) -> Ret
impl<Ret, A, B, C, D, E, F> Eq for extern "C" fn(_: A, _: B, _: C, _: D, _: E, _: F, ...) -> Ret
impl<Ret, A, B, C, D, E, F> Eq for unsafe fn(_: A, _: B, _: C, _: D, _: E, _: F) -> Ret
impl<Ret, A, B, C, D, E, F> Eq for unsafe extern "C" fn(_: A, _: B, _: C, _: D, _: E, _: F) -> Ret
impl<Ret, A, B, C, D, E, F> Eq for unsafe extern "C" fn(_: A, _: B, _: C, _: D, _: E, _: F, ...) -> Ret
impl<Ret, A, B, C, D, E, F, G> Eq for fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G) -> Ret
impl<Ret, A, B, C, D, E, F, G> Eq for extern "C" fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G) -> Ret
impl<Ret, A, B, C, D, E, F, G> Eq for extern "C" fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G, ...) -> Ret
impl<Ret, A, B, C, D, E, F, G> Eq for unsafe fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G) -> Ret
impl<Ret, A, B, C, D, E, F, G> Eq for unsafe extern "C" fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G) -> Ret
impl<Ret, A, B, C, D, E, F, G> Eq for unsafe extern "C" fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G, ...) -> Ret
impl<Ret, A, B, C, D, E, F, G, H> Eq for fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G, _: H) -> Ret
impl<Ret, A, B, C, D, E, F, G, H> Eq for extern "C" fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G, _: H) -> Ret
impl<Ret, A, B, C, D, E, F, G, H> Eq for extern "C" fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G, _: H, ...) -> Ret
impl<Ret, A, B, C, D, E, F, G, H> Eq for unsafe fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G, _: H) -> Ret
impl<Ret, A, B, C, D, E, F, G, H> Eq for unsafe extern "C" fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G, _: H) -> Ret
impl<Ret, A, B, C, D, E, F, G, H> Eq for unsafe extern "C" fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G, _: H, ...) -> Ret
impl<Ret, A, B, C, D, E, F, G, H, I> Eq for fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G, _: H, _: I) -> Ret
impl<Ret, A, B, C, D, E, F, G, H, I> Eq for extern "C" fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G, _: H, _: I) -> Ret
impl<Ret, A, B, C, D, E, F, G, H, I> Eq for extern "C" fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G, _: H, _: I, ...) -> Ret
impl<Ret, A, B, C, D, E, F, G, H, I> Eq for unsafe fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G, _: H, _: I) -> Ret
impl<Ret, A, B, C, D, E, F, G, H, I> Eq for unsafe extern "C" fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G, _: H, _: I) -> Ret
impl<Ret, A, B, C, D, E, F, G, H, I> Eq for unsafe extern "C" fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G, _: H, _: I, ...) -> Ret
impl<Ret, A, B, C, D, E, F, G, H, I, J> Eq for fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G, _: H, _: I, _: J) -> Ret
impl<Ret, A, B, C, D, E, F, G, H, I, J> Eq for extern "C" fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G, _: H, _: I, _: J) -> Ret
impl<Ret, A, B, C, D, E, F, G, H, I, J> Eq for extern "C" fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G, _: H, _: I, _: J, ...) -> Ret
impl<Ret, A, B, C, D, E, F, G, H, I, J> Eq for unsafe fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G, _: H, _: I, _: J) -> Ret
impl<Ret, A, B, C, D, E, F, G, H, I, J> Eq for unsafe extern "C" fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G, _: H, _: I, _: J) -> Ret
impl<Ret, A, B, C, D, E, F, G, H, I, J> Eq for unsafe extern "C" fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G, _: H, _: I, _: J, ...) -> Ret
impl<Ret, A, B, C, D, E, F, G, H, I, J, K> Eq for fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G, _: H, _: I, _: J, _: K) -> Ret
impl<Ret, A, B, C, D, E, F, G, H, I, J, K> Eq for extern "C" fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G, _: H, _: I, _: J, _: K) -> Ret
impl<Ret, A, B, C, D, E, F, G, H, I, J, K> Eq for extern "C" fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G, _: H, _: I, _: J, _: K, ...) -> Ret
impl<Ret, A, B, C, D, E, F, G, H, I, J, K> Eq for unsafe fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G, _: H, _: I, _: J, _: K) -> Ret
impl<Ret, A, B, C, D, E, F, G, H, I, J, K> Eq for unsafe extern "C" fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G, _: H, _: I, _: J, _: K) -> Ret
impl<Ret, A, B, C, D, E, F, G, H, I, J, K> Eq for unsafe extern "C" fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G, _: H, _: I, _: J, _: K, ...) -> Ret
impl<Ret, A, B, C, D, E, F, G, H, I, J, K, L> Eq for fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G, _: H, _: I, _: J, _: K, _: L) -> Ret
impl<Ret, A, B, C, D, E, F, G, H, I, J, K, L> Eq for extern "C" fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G, _: H, _: I, _: J, _: K, _: L) -> Ret
impl<Ret, A, B, C, D, E, F, G, H, I, J, K, L> Eq for extern "C" fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G, _: H, _: I, _: J, _: K, _: L, ...) -> Ret
impl<Ret, A, B, C, D, E, F, G, H, I, J, K, L> Eq for unsafe fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G, _: H, _: I, _: J, _: K, _: L) -> Ret
impl<Ret, A, B, C, D, E, F, G, H, I, J, K, L> Eq for unsafe extern "C" fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G, _: H, _: I, _: J, _: K, _: L) -> Ret
impl<Ret, A, B, C, D, E, F, G, H, I, J, K, L> Eq for unsafe extern "C" fn(_: A, _: B, _: C, _: D, _: E, _: F, _: G, _: H, _: I, _: J, _: K, _: L, ...) -> Ret
impl<T: ?Sized> Eq for NonNull<T>
impl<T: ?Sized> Eq for PhantomData<T>
impl<Y: Eq, R: Eq> Eq for GeneratorState<Y, R>
impl Eq for RangeFull
impl<Idx: Eq> Eq for Range<Idx>
impl<Idx: Eq> Eq for RangeFrom<Idx>
impl<Idx: Eq> Eq for RangeTo<Idx>
impl<Idx: Eq> Eq for RangeInclusive<Idx>
impl<Idx: Eq> Eq for RangeToInclusive<Idx>
impl<T: Eq> Eq for Bound<T>
impl Eq for ()
impl Eq for bool
impl Eq for char
impl Eq for usize
impl Eq for u8
impl Eq for u16
impl Eq for u32
impl Eq for u64
impl Eq for u128
impl Eq for isize
impl Eq for i8
impl Eq for i16
impl Eq for i32
impl Eq for i64
impl Eq for i128
impl Eq for !
impl<'a, A: ?Sized> Eq for &'a A where
A: Eq,impl<'a, A: ?Sized> Eq for &'a mut A where
A: Eq,impl<T: Eq> Eq for Reverse<T>
impl Eq for Ordering
impl Eq for TypeId
impl<T: Eq> Eq for [T; 0]
impl<T: Eq> Eq for [T; 1]
impl<T: Eq> Eq for [T; 2]
impl<T: Eq> Eq for [T; 3]
impl<T: Eq> Eq for [T; 4]
impl<T: Eq> Eq for [T; 5]
impl<T: Eq> Eq for [T; 6]
impl<T: Eq> Eq for [T; 7]
impl<T: Eq> Eq for [T; 8]
impl<T: Eq> Eq for [T; 9]
impl<T: Eq> Eq for [T; 10]
impl<T: Eq> Eq for [T; 11]
impl<T: Eq> Eq for [T; 12]
impl<T: Eq> Eq for [T; 13]
impl<T: Eq> Eq for [T; 14]
impl<T: Eq> Eq for [T; 15]
impl<T: Eq> Eq for [T; 16]
impl<T: Eq> Eq for [T; 17]
impl<T: Eq> Eq for [T; 18]
impl<T: Eq> Eq for [T; 19]
impl<T: Eq> Eq for [T; 20]
impl<T: Eq> Eq for [T; 21]
impl<T: Eq> Eq for [T; 22]
impl<T: Eq> Eq for [T; 23]
impl<T: Eq> Eq for [T; 24]
impl<T: Eq> Eq for [T; 25]
impl<T: Eq> Eq for [T; 26]
impl<T: Eq> Eq for [T; 27]
impl<T: Eq> Eq for [T; 28]
impl<T: Eq> Eq for [T; 29]
impl<T: Eq> Eq for [T; 30]
impl<T: Eq> Eq for [T; 31]
impl<T: Eq> Eq for [T; 32]
impl<T: Eq + Copy> Eq for Cell<T>
impl<T: ?Sized + Eq> Eq for RefCell<T>
impl Eq for ParseCharError
impl Eq for CharTryFromError
impl Eq for InvalidSequence
impl Eq for DecodeUtf16Error
impl<T: Eq> Eq for Option<T>
impl Eq for NoneError
impl<T: Eq, E: Eq> Eq for Result<T, E>
impl<T: Eq> Eq for [T]
impl Eq for SearchStep
impl<'a> Eq for Utf8LossyChunk<'a>
impl Eq for str
impl Eq for ParseBoolError
impl Eq for Utf8Error
impl Eq for Error
impl Eq for Duration
impl Eq for UnicodeVersion
impl Eq for Layout
impl Eq for LayoutErr
impl Eq for AllocErr
impl Eq for CannotReallocInPlace
impl Eq for CollectionAllocErr
impl<A> Eq for (A,) where
A: Eq + ?Sized,impl<A: Eq, B> Eq for (A, B) where
B: Eq + ?Sized,impl<A: Eq, B: Eq, C> Eq for (A, B, C) where
C: Eq + ?Sized,impl<A: Eq, B: Eq, C: Eq, D> Eq for (A, B, C, D) where
D: Eq + ?Sized,impl<A: Eq, B: Eq, C: Eq, D: Eq, E> Eq for (A, B, C, D, E) where
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,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,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,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,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,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,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,impl Eq for i8x16
impl Eq for u8x16
impl Eq for m8x16
impl Eq for i16x8
impl Eq for u16x8
impl Eq for m16x8
impl Eq for i32x4
impl Eq for u32x4
impl Eq for m32x4
impl Eq for i64x2
impl Eq for u64x2
impl Eq for m64x2
impl Eq for i8x2
impl Eq for u8x2
impl Eq for m8x2
impl Eq for i8x32
impl Eq for u8x32
impl Eq for m8x32
impl Eq for i16x16
impl Eq for u16x16
impl Eq for m16x16
impl Eq for i32x8
impl Eq for u32x8
impl Eq for m32x8
impl Eq for i64x4
impl Eq for u64x4
impl Eq for m64x4
impl Eq for i16x2
impl Eq for u16x2
impl Eq for m16x2
impl Eq for i8x4
impl Eq for u8x4
impl Eq for m8x4
impl Eq for i8x64
impl Eq for u8x64
impl Eq for m1x64
impl Eq for i16x32
impl Eq for u16x32
impl Eq for m1x32
impl Eq for i32x16
impl Eq for u32x16
impl Eq for m1x16
impl Eq for i64x8
impl Eq for u64x8
impl Eq for m1x8
impl Eq for i8x8
impl Eq for u8x8
impl Eq for m8x8
impl Eq for i16x4
impl Eq for u16x4
impl Eq for m16x4
impl Eq for i32x2
impl Eq for u32x2
impl Eq for m32x2
impl Eq for CpuidResult