Trait std::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: &Book) -> bool { self.isbn == other.isbn } } impl Eq for Book {}Run
Implementations on Foreign Types
impl Eq for InvalidSequence[src]
impl Eq for InvalidSequenceimpl<T> Eq for NonZero<T> where
T: Zeroable + Eq, [src]
impl<T> Eq for NonZero<T> where
T: Zeroable + Eq, impl Eq for CpuidResult[src]
impl Eq for CpuidResultimpl<'a> Eq for Utf8LossyChunk<'a>[src]
impl<'a> Eq for Utf8LossyChunk<'a>Implementors
impl Eq for u16x8impl<Ret, A, B, C, D, E, F> Eq for unsafe extern "C" fn(A, B, C, D, E, F) -> Retimpl<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, ...) -> Retimpl<T> Eq for [T; 1] where
T: Eq,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, ...) -> Retimpl<T> Eq for [T; 8] where
T: Eq,impl<T> Eq for [T; 21] where
T: Eq,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) -> Retimpl<Ret, A, B, C, D, E, F, G, H> Eq for fn(A, B, C, D, E, F, G, H) -> Retimpl<Ret, A, B, C> Eq for extern "C" fn(A, B, C, ...) -> Retimpl<Ret, A, B, C, D, E, F, G, H, I, J> Eq for fn(A, B, C, D, E, F, G, H, I, J) -> Retimpl<T> Eq for [T; 15] where
T: Eq,impl<T> Eq for [T; 20] where
T: Eq,impl Eq for ()impl Eq for u64x2impl Eq for i64x4impl Eq for CharTryFromErrorimpl Eq for u32x8impl Eq for u16x16impl Eq for i32x2impl Eq for NonZeroU32impl Eq for i64x2impl Eq for b8x2impl<T> Eq for [T; 24] where
T: Eq,impl<T> Eq for [T; 9] where
T: Eq,impl<T> Eq for PhantomData<T> where
T: ?Sized,impl<T> Eq for Wrapping<T> where
T: Eq,impl<T> Eq for [T; 22] where
T: Eq,impl<A, B, C, D, E, F, G> Eq for (A, B, C, D, E, F, G) where
A: Eq,
B: Eq,
C: Eq,
D: Eq,
E: Eq,
F: Eq,
G: Eq + ?Sized,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) -> Retimpl<A, B, C, D> Eq for (A, B, C, D) where
A: Eq,
B: Eq,
C: Eq,
D: Eq + ?Sized,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) -> Retimpl<Ret, A, B> Eq for unsafe extern "C" fn(A, B) -> Retimpl<T> Eq for [T] where
T: Eq,impl<T> Eq for [T; 32] where
T: Eq,impl<Ret, A, B, C, D, E> Eq for unsafe fn(A, B, C, D, E) -> Retimpl<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) -> Retimpl Eq for i32x4impl Eq for i8x16impl Eq for u32x16impl<A, B, C, D, E> Eq for (A, B, C, D, E) where
A: Eq,
B: Eq,
C: Eq,
D: Eq,
E: Eq + ?Sized,impl Eq for u128impl<Ret, A, B, C, D, E> Eq for fn(A, B, C, D, E) -> Retimpl<Ret, A, B> Eq for unsafe extern "C" fn(A, B, ...) -> Retimpl<T> Eq for [T; 0] where
T: Eq,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) -> Retimpl Eq for u64x8impl<T> Eq for [T; 5] where
T: Eq,impl Eq for FpCategoryimpl<Idx> Eq for RangeInclusive<Idx> where
Idx: Eq,impl<Ret, A> Eq for fn(A) -> Retimpl<Ret, A, B, C, D> Eq for extern "C" fn(A, B, C, D) -> Retimpl Eq for i16x8impl<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, ...) -> Retimpl<Ret, A, B, C, D, E, F, G, H> Eq for unsafe fn(A, B, C, D, E, F, G, H) -> Retimpl<A, B, C, D, E, F, G, H> Eq for (A, B, C, D, E, F, G, H) where
A: Eq,
B: Eq,
C: Eq,
D: Eq,
E: Eq,
F: Eq,
G: Eq,
H: Eq + ?Sized,impl<T> Eq for [T; 12] where
T: Eq,impl Eq for i8x64impl<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) -> Retimpl Eq for u8x32impl Eq for i8x2impl<T> Eq for [T; 2] where
T: Eq,impl<Ret, A, B, C, D, E, F, G, H, I> Eq for fn(A, B, C, D, E, F, G, H, I) -> Retimpl Eq for u32impl<Ret, A, B, C, D, E, F, G, H, I> Eq for extern "C" fn(A, B, C, D, E, F, G, H, I) -> Retimpl Eq for i16x2impl Eq for SearchStepimpl<Ret, A, B, C> Eq for unsafe extern "C" fn(A, B, C) -> Retimpl<Ret, A, B, C, D, E, F, G, H, I> Eq for unsafe fn(A, B, C, D, E, F, G, H, I) -> Retimpl<Ret, A, B, C, D, E, F, G, H> Eq for unsafe extern "C" fn(A, B, C, D, E, F, G, H) -> Retimpl<Ret, A, B, C, D, E, F, G, H, I> Eq for extern "C" fn(A, B, C, D, E, F, G, H, I, ...) -> Retimpl Eq for u16x32impl<Idx> Eq for RangeTo<Idx> where
Idx: Eq,impl Eq for RangeFullimpl Eq for b8x32impl<Ret, A, B, C, D, E, F, G> Eq for unsafe extern "C" fn(A, B, C, D, E, F, G) -> Retimpl Eq for u8x16impl<T> Eq for Bound<T> where
T: Eq,impl<T> Eq for [T; 17] where
T: Eq,impl<T> Eq for [T; 30] where
T: Eq,impl Eq for NonZeroIsizeimpl<Ret, A, B, C, D, E, F> Eq for extern "C" fn(A, B, C, D, E, F) -> Retimpl Eq for u32x2impl<T> Eq for [T; 27] where
T: Eq,impl<Ret> Eq for fn() -> Retimpl<T> Eq for *const T where
T: ?Sized,impl<Ret> Eq for extern "C" fn() -> Retimpl<Ret, A, B, C, D> Eq for fn(A, B, C, D) -> Retimpl<T> Eq for ManuallyDrop<T> where
T: Eq,impl<Ret, A, B, C, D, E, F, G> Eq for unsafe fn(A, B, C, D, E, F, G) -> Retimpl Eq for b8x4impl Eq for NonZeroU64impl Eq for boolimpl<Idx> Eq for Range<Idx> where
Idx: Eq,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, ...) -> Retimpl Eq for i16impl<Ret> Eq for unsafe fn() -> Retimpl Eq for NoneErrorimpl<T> Eq for [T; 28] where
T: Eq,impl<Ret, A, B, C, D, E> Eq for extern "C" fn(A, B, C, D, E) -> Retimpl Eq for Errorimpl<T> Eq for [T; 4] where
T: Eq,impl<Ret, A, B, C, D, E, F, G> Eq for unsafe extern "C" fn(A, B, C, D, E, F, G, ...) -> Retimpl<A, B, C, D, E, F> Eq for (A, B, C, D, E, F) where
A: Eq,
B: Eq,
C: Eq,
D: Eq,
E: Eq,
F: Eq + ?Sized,impl Eq for NonZeroI128impl<T> Eq for [T; 6] where
T: Eq,impl Eq for i8x8impl Eq for i8impl<T> Eq for [T; 3] where
T: Eq,impl Eq for NonZeroI8impl Eq for u8impl Eq for isizeimpl Eq for i32x8impl<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, ...) -> Retimpl<T> Eq for [T; 23] where
T: Eq,impl<Ret, A, B, C, D, E, F> Eq for extern "C" fn(A, B, C, D, E, F, ...) -> Retimpl Eq for u64x4impl Eq for NonZeroI32impl Eq for strimpl<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) -> Retimpl Eq for ParseBoolErrorimpl<Ret, A> Eq for extern "C" fn(A) -> Retimpl<Ret, A, B, C, D> Eq for unsafe extern "C" fn(A, B, C, D) -> Retimpl<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) -> Retimpl<A, B> Eq for (A, B) where
A: Eq,
B: Eq + ?Sized,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, ...) -> Retimpl<T> Eq for Discriminant<T>impl<T> Eq for [T; 29] where
T: Eq,impl<A, B, C> Eq for (A, B, C) where
A: Eq,
B: Eq,
C: Eq + ?Sized,impl Eq for i8x32impl<Ret, A, B, C, D, E, F> Eq for unsafe extern "C" fn(A, B, C, D, E, F, ...) -> Retimpl Eq for u8x2impl Eq for TypeIdimpl<Ret, A, B, C> Eq for fn(A, B, C) -> Retimpl Eq for u8x4impl<T> Eq for *mut T where
T: ?Sized,impl<T> Eq for NonNull<T> where
T: ?Sized,impl<Ret, A, B, C, D> Eq for extern "C" fn(A, B, C, D, ...) -> Retimpl<Ret, A, B, C, D, E> Eq for unsafe extern "C" fn(A, B, C, D, E) -> Retimpl<Idx> Eq for RangeToInclusive<Idx> where
Idx: Eq,impl<Ret, A, B> Eq for fn(A, B) -> Retimpl<Ret, A, B, C> Eq for unsafe extern "C" fn(A, B, C, ...) -> Retimpl Eq for i16x16impl<A, B, C, D, E, F, G, H, I, J, K> Eq for (A, B, C, D, E, F, G, H, I, J, K) where
A: Eq,
B: Eq,
C: Eq,
D: Eq,
E: Eq,
F: Eq,
G: Eq,
H: Eq,
I: Eq,
J: Eq,
K: Eq + ?Sized,impl Eq for i128impl Eq for NonZeroI16impl<Ret, A> Eq for unsafe fn(A) -> Retimpl Eq for i16x32impl<T> Eq for [T; 14] where
T: Eq,impl Eq for i64x8impl Eq for b8x16impl<A, B, C, D, E, F, G, H, I, J> Eq for (A, B, C, D, E, F, G, H, I, J) where
A: Eq,
B: Eq,
C: Eq,
D: Eq,
E: Eq,
F: Eq,
G: Eq,
H: Eq,
I: Eq,
J: Eq + ?Sized,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, ...) -> Retimpl<T> Eq for [T; 16] where
T: Eq,impl<Ret, A, B, C> Eq for extern "C" fn(A, B, C) -> Retimpl Eq for NonZeroU16impl<T> Eq for [T; 11] where
T: Eq,impl<Y, R> Eq for GeneratorState<Y, R> where
R: Eq,
Y: Eq,impl<'a, A> Eq for &'a mut A where
A: Eq + ?Sized,impl Eq for i32x16impl Eq for u64impl<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) -> Retimpl<Ret, A, B, C, D, E, F, G> Eq for fn(A, B, C, D, E, F, G) -> Retimpl<'a, A> Eq for &'a A where
A: Eq + ?Sized,impl<T> Eq for [T; 19] where
T: Eq,impl<T> Eq for Cell<T> where
T: Copy + Eq,impl<Ret, A, B> Eq for unsafe fn(A, B) -> Retimpl Eq for ParseFloatErrorimpl Eq for Utf8Errorimpl Eq for ParseIntErrorimpl<T, E> Eq for Result<T, E> where
E: Eq,
T: Eq,impl Eq for !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) -> Retimpl Eq for i8x4impl<Ret, A> Eq for unsafe extern "C" fn(A) -> Retimpl<T> Eq for [T; 7] where
T: Eq,impl<Ret, A, B, C, D, E> Eq for extern "C" fn(A, B, C, D, E, ...) -> Retimpl Eq for Durationimpl<T> Eq for [T; 13] where
T: Eq,impl<Ret, A, B> Eq for extern "C" fn(A, B, ...) -> Retimpl<Ret, A, B, C, D, E, F, G> Eq for extern "C" fn(A, B, C, D, E, F, G, ...) -> Retimpl<Ret, A, B> Eq for extern "C" fn(A, B) -> Retimpl<T> Eq for [T; 31] where
T: Eq,impl<Ret> Eq for unsafe extern "C" fn() -> Retimpl Eq for u8x64impl Eq for b8x64impl Eq for u16impl<Ret, A, B, C, D, E, F, G, H> Eq for unsafe extern "C" fn(A, B, C, D, E, F, G, H, ...) -> Retimpl Eq for NonZeroUsizeimpl<A, B, C, D, E, F, G, H, I> Eq for (A, B, C, D, E, F, G, H, I) where
A: Eq,
B: Eq,
C: Eq,
D: Eq,
E: Eq,
F: Eq,
G: Eq,
H: Eq,
I: Eq + ?Sized,impl Eq for u16x4impl<A, B, C, D, E, F, G, H, I, J, K, L> Eq for (A, B, C, D, E, F, G, H, I, J, K, L) where
A: Eq,
B: Eq,
C: Eq,
D: Eq,
E: Eq,
F: Eq,
G: Eq,
H: Eq,
I: Eq,
J: Eq,
K: Eq,
L: Eq + ?Sized,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) -> Retimpl<T> Eq for [T; 25] where
T: Eq,impl Eq for charimpl Eq for i32impl Eq for NonZeroU128impl<T> Eq for [T; 10] where
T: Eq,impl<T> Eq for Reverse<T> where
T: Eq,impl<Ret, A, B, C, D, E, F> Eq for fn(A, B, C, D, E, F) -> Retimpl<Ret, A, B, C, D, E> Eq for unsafe extern "C" fn(A, B, C, D, E, ...) -> Retimpl Eq for usizeimpl<Ret, A, B, C, D, E, F, G> Eq for extern "C" fn(A, B, C, D, E, F, G) -> Retimpl<Ret, A> Eq for extern "C" fn(A, ...) -> Retimpl<Ret, A, B, C, D, E, F, G, H> Eq for extern "C" fn(A, B, C, D, E, F, G, H, ...) -> Retimpl<T> Eq for Option<T> where
T: Eq,impl Eq for Orderingimpl<T> Eq for RefCell<T> where
T: Eq + ?Sized,impl Eq for i64impl<Ret, A, B, C, D, E, F> Eq for unsafe fn(A, B, C, D, E, F) -> Retimpl<Ret, A, B, C, D> Eq for unsafe extern "C" fn(A, B, C, D, ...) -> Retimpl Eq for u32x4impl<Ret, A> Eq for unsafe extern "C" fn(A, ...) -> Retimpl Eq for b8x8impl Eq for ParseCharErrorimpl<Ret, A, B, C> Eq for unsafe fn(A, B, C) -> Retimpl<Ret, A, B, C, D> Eq for unsafe fn(A, B, C, D) -> Retimpl<Ret, A, B, C, D, E, F, G, H> Eq for extern "C" fn(A, B, C, D, E, F, G, H) -> Retimpl<Idx> Eq for RangeFrom<Idx> where
Idx: Eq,impl Eq for u16x2impl<T> Eq for [T; 26] where
T: Eq,impl<A> Eq for (A,) where
A: Eq + ?Sized,impl Eq for NonZeroI64impl<T> Eq for [T; 18] where
T: Eq,impl Eq for NonZeroU8impl Eq for u8x8impl Eq for i16x4impl<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) -> Retimpl<T> Eq for Rc<T> where
T: Eq + ?Sized,impl Eq for CollectionAllocErrimpl Eq for AllocErrimpl<T> Eq for LinkedList<T> where
T: Eq,impl Eq for Layoutimpl Eq for Stringimpl<A> Eq for VecDeque<A> where
A: Eq,impl<'a, B> Eq for Cow<'a, B> where
B: Eq + ToOwned + ?Sized,impl<K, V> Eq for BTreeMap<K, V> where
K: Eq,
V: Eq,impl<T> Eq for Box<T> where
T: Eq + ?Sized,impl<T> Eq for Arc<T> where
T: Eq + ?Sized,impl Eq for ParseErrorimpl<T> Eq for Vec<T> where
T: Eq,impl<T> Eq for BTreeSet<T> where
T: Eq,impl Eq for CannotReallocInPlaceimpl Eq for UnicodeVersionimpl Eq for DecodeUtf16Errorimpl Eq for ThreadIdimpl<K, V, S> Eq for HashMap<K, V, S> where
K: Eq + Hash,
V: Eq,
S: BuildHasher,impl<T, S> Eq for HashSet<T, S> where
T: Eq + Hash,
S: BuildHasher,impl Eq for VarErrorimpl Eq for CStringimpl Eq for NulErrorimpl Eq for FromBytesWithNulErrorimpl Eq for IntoStringErrorimpl Eq for CStrimpl Eq for OsStringimpl Eq for OsStrimpl Eq for Permissionsimpl Eq for FileTypeimpl Eq for ErrorKindimpl Eq for SeekFromimpl Eq for IpAddrimpl Eq for Ipv6MulticastScopeimpl Eq for Ipv4Addrimpl Eq for Ipv6Addrimpl Eq for SocketAddrimpl Eq for SocketAddrV4impl Eq for SocketAddrV6impl Eq for AddrParseErrorimpl Eq for Shutdownimpl<'a> Eq for Prefix<'a>impl<'a> Eq for PrefixComponent<'a>impl<'a> Eq for Component<'a>impl<'a> Eq for Components<'a>impl Eq for ParsePathErrorimpl Eq for PathBufimpl Eq for StripPrefixErrorimpl Eq for Pathimpl Eq for Outputimpl Eq for ExitStatusimpl<T: Eq> Eq for SendError<T>impl Eq for RecvErrorimpl Eq for TryRecvErrorimpl Eq for RecvTimeoutErrorimpl<T: Eq> Eq for TrySendError<T>impl Eq for WaitTimeoutResultimpl Eq for Instantimpl Eq for SystemTime