# 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` implies `b == a`; and
- transitive: `a == b` and `b == c` implies `a == 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<T: Eq> Eq for Wrapping<T>`
- `impl Eq for FpCategory`
- `impl Eq for ParseIntError`
- `impl<T> Eq for Discriminant<T>`
- `impl<T: Eq + Zeroable> Eq for NonZero<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 fn() -> Ret`
- `impl<Ret> Eq for unsafe fn() -> Ret`
- `impl<Ret> Eq for unsafe extern fn() -> Ret`
- `impl<Ret, A> Eq for fn(A) -> Ret`
- `impl<Ret, A> Eq for extern fn(A) -> Ret`
- `impl<Ret, A> Eq for extern fn(A, ...) -> Ret`
- `impl<Ret, A> Eq for unsafe fn(A) -> Ret`
- `impl<Ret, A> Eq for unsafe extern fn(A) -> Ret`
- `impl<Ret, A> Eq for unsafe extern fn(A, ...) -> Ret`
- `impl<Ret, A, B> Eq for fn(A, B) -> Ret`
- `impl<Ret, A, B> Eq for extern fn(A, B) -> Ret`
- `impl<Ret, A, B> Eq for extern fn(A, B, ...) -> Ret`
- `impl<Ret, A, B> Eq for unsafe fn(A, B) -> Ret`
- `impl<Ret, A, B> Eq for unsafe extern fn(A, B) -> Ret`
- `impl<Ret, A, B> Eq for unsafe extern fn(A, B, ...) -> Ret`
- `impl<Ret, A, B, C> Eq for fn(A, B, C) -> Ret`
- `impl<Ret, A, B, C> Eq for extern fn(A, B, C) -> Ret`
- `impl<Ret, A, B, C> Eq for extern 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 fn(A, B, C) -> Ret`
- `impl<Ret, A, B, C> Eq for unsafe extern 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 fn(A, B, C, D) -> Ret`
- `impl<Ret, A, B, C, D> Eq for extern 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 fn(A, B, C, D) -> Ret`
- `impl<Ret, A, B, C, D> Eq for unsafe extern 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 fn(A, B, C, D, E) -> Ret`
- `impl<Ret, A, B, C, D, E> Eq for extern 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 fn(A, B, C, D, E) -> Ret`
- `impl<Ret, A, B, C, D, E> Eq for unsafe extern 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 fn(A, B, C, D, E, F) -> Ret`
- `impl<Ret, A, B, C, D, E, F> Eq for extern 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 fn(A, B, C, D, E, F) -> Ret`
- `impl<Ret, A, B, C, D, E, F> Eq for unsafe extern 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 fn(A, B, C, D, E, F, G) -> Ret`
- `impl<Ret, A, B, C, D, E, F, G> Eq for extern 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 fn(A, B, C, D, E, F, G) -> Ret`
- `impl<Ret, A, B, C, D, E, F, G> Eq for unsafe extern 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 fn(A, B, C, D, E, F, G, H) -> Ret`
- `impl<Ret, A, B, C, D, E, F, G, H> Eq for extern 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 fn(A, B, C, D, E, F, G, H) -> Ret`
- `impl<Ret, A, B, C, D, E, F, G, H> Eq for unsafe extern 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 fn(A, B, C, D, E, F, G, H, I, J, K, L, ...) -> Ret`
- `impl<T: ?Sized> Eq for PhantomData<T>`
- `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 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 isize`
- `impl Eq for i8`
- `impl Eq for i16`
- `impl Eq for i32`
- `impl Eq for i64`
- `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 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 Eq for BorrowState`
- `impl<T: ?Sized + Eq> Eq for RefCell<T>`
- `impl Eq for CharTryFromError`
- `impl Eq for InvalidSequence`
- `impl<T: Eq> Eq for Option<T>`
- `impl<T: Eq, E: Eq> Eq for Result<T, E>`
- `impl<T: Eq> Eq for [T]`
- `impl Eq for SearchStep`
- `impl Eq for str`
- `impl Eq for ParseBoolError`
- `impl Eq for Utf8Error`
- `impl Eq for Error`
- `impl<A: Eq> Eq for (A,)`
- `impl<A: Eq, B: Eq> Eq for (A, B)`
- `impl<A: Eq, B: Eq, C: Eq> Eq for (A, B, C)`
- `impl<A: Eq, B: Eq, C: Eq, D: Eq> Eq for (A, B, C, D)`
- `impl<A: Eq, B: Eq, C: Eq, D: Eq, E: Eq> Eq for (A, B, C, D, E)`
- `impl<A: Eq, B: Eq, C: Eq, D: Eq, E: Eq, F: Eq> Eq for (A, B, C, D, E, F)`
- `impl<A: Eq, B: Eq, C: Eq, D: Eq, E: Eq, F: Eq, G: Eq> Eq for (A, B, C, D, E, F, G)`
- `impl<A: Eq, B: Eq, C: Eq, D: Eq, E: Eq, F: Eq, G: Eq, H: Eq> Eq for (A, B, C, D, E, F, G, H)`
- `impl<A: Eq, B: Eq, C: Eq, D: Eq, E: Eq, F: Eq, G: Eq, H: Eq, I: Eq> Eq for (A, B, C, D, E, F, G, H, I)`
- `impl<A: Eq, B: Eq, C: Eq, D: Eq, E: Eq, F: Eq, G: Eq, H: Eq, I: Eq, J: Eq> Eq for (A, B, C, D, E, F, G, H, I, J)`
- `impl<A: Eq, B: Eq, C: Eq, D: Eq, E: Eq, F: Eq, G: Eq, H: Eq, I: Eq, J: Eq, K: Eq> Eq for (A, B, C, D, E, F, G, H, I, J, K)`
- `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> Eq for (A, B, C, D, E, F, G, H, I, J, K, L)`

# Help

## Keyboard Shortcuts

?
  Show this help dialog
S
  Focus the search field
⇤
  Move up in search results
⇥
  Move down in search results
⏎
  Go to active search result
+
  Collapse/expand all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize` or `* -> vec`)