Trait std::cmp::Eq

1.0.0 · source ·
pub trait Eq: PartialEq { }
Expand description

Trait for comparisons corresponding to equivalence relations.

This means, that in addition to a == b and a != b being strict inverses, the relation must be (for all a, b and c):

  • reflexive: a == a;
  • symmetric: a == b implies b == a (required by PartialEq as well); and
  • transitive: a == b and b == c implies a == c (required by PartialEq as well).

This property cannot be checked by the compiler, and therefore Eq implies PartialEq, and has no extra methods.

Violating this property is a logic error. The behavior resulting from a logic error is not specified, but users of the trait must ensure that such logic errors do not result in undefined behavior. This means that unsafe code must not rely on the correctness of these methods.

Implement Eq in addition to PartialEq if it’s guaranteed that PartialEq::eq(a, a) always returns true (reflexivity), in addition to the symmetric and transitive properties already required by PartialEq.

§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

Object Safety§

This trait is not object safe.

Implementors§

source§

impl Eq for AsciiChar

1.65.0 · source§

impl Eq for BacktraceStatus

source§

impl Eq for TryReserveErrorKind

1.34.0 · source§

impl Eq for Infallible

source§

impl Eq for VarError

1.28.0 · source§

impl Eq for std::fmt::Alignment

source§

impl Eq for ErrorKind

source§

impl Eq for SeekFrom

1.7.0 · source§

impl Eq for IpAddr

source§

impl Eq for Ipv6MulticastScope

source§

impl Eq for Shutdown

source§

impl Eq for SocketAddr

source§

impl Eq for FpCategory

1.55.0 · source§

impl Eq for IntErrorKind

source§

impl Eq for BacktraceStyle

source§

impl Eq for SearchStep

source§

impl Eq for std::sync::atomic::Ordering

1.12.0 · source§

impl Eq for RecvTimeoutError

source§

impl Eq for TryRecvError

source§

impl Eq for std::cmp::Ordering

source§

impl Eq for DwarfFileType

source§

impl Eq for Format

source§

impl Eq for SectionId

source§

impl Eq for Vendor

source§

impl Eq for RunTimeEndian

source§

impl Eq for AbbreviationsCacheStrategy

source§

impl Eq for Pointer

source§

impl Eq for gimli::read::Error

source§

impl Eq for ColumnType

source§

impl Eq for ValueType

source§

impl Eq for bool

source§

impl Eq for char

source§

impl Eq for i8

source§

impl Eq for i16

source§

impl Eq for i32

source§

impl Eq for i64

source§

impl Eq for i128

source§

impl Eq for isize

source§

impl Eq for !

source§

impl Eq for str

source§

impl Eq for u8

source§

impl Eq for u16

source§

impl Eq for u32

source§

impl Eq for u64

source§

impl Eq for u128

source§

impl Eq for ()

source§

impl Eq for usize

1.27.0 · source§

impl Eq for CpuidResult

source§

impl Eq for AllocError

1.28.0 · source§

impl Eq for Layout

1.50.0 · source§

impl Eq for LayoutError

source§

impl Eq for TypeId

1.34.0 · source§

impl Eq for CharTryFromError

1.9.0 · source§

impl Eq for DecodeUtf16Error

1.20.0 · source§

impl Eq for ParseCharError

1.59.0 · source§

impl Eq for TryFromCharError

source§

impl Eq for UnorderedKeyError

1.57.0 · source§

impl Eq for TryReserveError

1.69.0 · source§

impl Eq for FromBytesUntilNulError

1.64.0 · source§

impl Eq for FromBytesWithNulError

1.64.0 · source§

impl Eq for FromVecWithNulError

1.64.0 · source§

impl Eq for IntoStringError

1.64.0 · source§

impl Eq for NulError

source§

impl Eq for CStr

1.64.0 · source§

impl Eq for CString

source§

impl Eq for OsStr

source§

impl Eq for OsString

source§

impl Eq for std::fmt::Error

1.1.0 · source§

impl Eq for FileType

source§

impl Eq for Permissions

1.33.0 · source§

impl Eq for PhantomPinned

source§

impl Eq for Assume

source§

impl Eq for AddrParseError

source§

impl Eq for Ipv4Addr

source§

impl Eq for Ipv6Addr

source§

impl Eq for SocketAddrV4

source§

impl Eq for SocketAddrV6

source§

impl Eq for ParseFloatError

source§

impl Eq for ParseIntError

1.34.0 · source§

impl Eq for TryFromIntError

source§

impl Eq for RangeFull

source§

impl Eq for UCred

Available on Unix only.
1.63.0 · source§

impl Eq for InvalidHandleError

Available on Windows only.
1.63.0 · source§

impl Eq for NullHandleError

Available on Windows only.
source§

impl Eq for Components<'_>

source§

impl Eq for Path

source§

impl Eq for PathBuf

1.7.0 · source§

impl Eq for StripPrefixError

source§

impl Eq for ExitStatus

source§

impl Eq for ExitStatusError

source§

impl Eq for Output

source§

impl Eq for std::ptr::Alignment

source§

impl Eq for ParseBoolError

source§

impl Eq for Utf8Error

source§

impl Eq for FromUtf8Error

source§

impl Eq for String

source§

impl Eq for RecvError

1.5.0 · source§

impl Eq for WaitTimeoutResult

1.26.0 · source§

impl Eq for AccessError

1.19.0 · source§

impl Eq for ThreadId

1.3.0 · source§

impl Eq for Duration

1.8.0 · source§

impl Eq for Instant

1.8.0 · source§

impl Eq for SystemTime

1.66.0 · source§

impl Eq for TryFromFloatSecsError

source§

impl Eq for DebugTypeSignature

source§

impl Eq for DwoId

source§

impl Eq for Encoding

source§

impl Eq for LineEncoding

source§

impl Eq for Register

source§

impl Eq for DwAccess

source§

impl Eq for DwAddr

source§

impl Eq for DwAt

source§

impl Eq for DwAte

source§

impl Eq for DwCc

source§

impl Eq for DwCfa

source§

impl Eq for DwChildren

source§

impl Eq for DwDefaulted

source§

impl Eq for DwDs

source§

impl Eq for DwDsc

source§

impl Eq for DwEhPe

source§

impl Eq for DwEnd

source§

impl Eq for DwForm

source§

impl Eq for DwId

source§

impl Eq for DwIdx

source§

impl Eq for DwInl

source§

impl Eq for DwLang

source§

impl Eq for DwLle

source§

impl Eq for DwLnct

source§

impl Eq for DwLne

source§

impl Eq for DwLns

source§

impl Eq for DwMacro

source§

impl Eq for DwOp

source§

impl Eq for DwOrd

source§

impl Eq for DwRle

source§

impl Eq for DwSect

source§

impl Eq for DwSectV2

source§

impl Eq for DwTag

source§

impl Eq for DwUt

source§

impl Eq for DwVirtuality

source§

impl Eq for DwVis

source§

impl Eq for BigEndian

source§

impl Eq for LittleEndian

source§

impl Eq for Abbreviation

source§

impl Eq for AttributeSpecification

source§

impl Eq for ArangeEntry

source§

impl Eq for Augmentation

source§

impl Eq for BaseAddresses

source§

impl Eq for SectionBaseAddresses

source§

impl Eq for UnitIndexSection

source§

impl Eq for FileEntryFormat

source§

impl Eq for LineRow

source§

impl Eq for ReaderOffsetId

source§

impl Eq for gimli::read::rnglists::Range

source§

impl Eq for StoreOnHeap

source§

impl<'a> Eq for Component<'a>

source§

impl<'a> Eq for Prefix<'a>

1.10.0 · source§

impl<'a> Eq for Location<'a>

source§

impl<'a> Eq for PrefixComponent<'a>

source§

impl<'a> Eq for Utf8Chunk<'a>

source§

impl<'bases, Section, R> Eq for CieOrFde<'bases, Section, R>
where Section: Eq + UnwindSection<R>, R: Eq + Reader,

source§

impl<'bases, Section, R> Eq for PartialFrameDescriptionEntry<'bases, Section, R>
where Section: Eq + UnwindSection<R>, R: Eq + Reader, <R as Reader>::Offset: Eq, <Section as UnwindSection<R>>::Offset: Eq,

source§

impl<'input, Endian> Eq for EndianSlice<'input, Endian>
where Endian: Eq + Endianity,

source§

impl<A> Eq for &A
where A: Eq + ?Sized,

source§

impl<A> Eq for &mut A
where A: Eq + ?Sized,

source§

impl<B> Eq for Cow<'_, B>
where B: Eq + ToOwned + ?Sized,

1.55.0 · source§

impl<B, C> Eq for ControlFlow<B, C>
where B: Eq, C: Eq,

source§

impl<Dyn> Eq for DynMetadata<Dyn>
where Dyn: ?Sized,

1.4.0 · source§

impl<F> Eq for F
where F: FnPtr,

1.29.0 · source§

impl<H> Eq for BuildHasherDefault<H>

source§

impl<Idx> Eq for std::ops::Range<Idx>
where Idx: Eq,

source§

impl<Idx> Eq for RangeFrom<Idx>
where Idx: Eq,

1.26.0 · source§

impl<Idx> Eq for RangeInclusive<Idx>
where Idx: Eq,

source§

impl<Idx> Eq for RangeTo<Idx>
where Idx: Eq,

1.26.0 · source§

impl<Idx> Eq for RangeToInclusive<Idx>
where Idx: Eq,

source§

impl<K, V, A> Eq for BTreeMap<K, V, A>
where K: Eq, V: Eq, A: Allocator + Clone,

source§

impl<K, V, S> Eq for HashMap<K, V, S>
where K: Eq + Hash, V: Eq, S: BuildHasher,

source§

impl<Offset> Eq for UnitType<Offset>
where Offset: Eq + ReaderOffset,

1.41.0 · source§

impl<Ptr> Eq for Pin<Ptr>
where Ptr: Deref, <Ptr as Deref>::Target: Eq,

source§

impl<R> Eq for CallFrameInstruction<R>
where R: Eq + Reader,

source§

impl<R> Eq for CfaRule<R>
where R: Eq + Reader,

source§

impl<R> Eq for RegisterRule<R>
where R: Eq + Reader,

source§

impl<R> Eq for DebugFrame<R>
where R: Eq + Reader,

source§

impl<R> Eq for EhFrame<R>
where R: Eq + Reader,

source§

impl<R> Eq for EhFrameHdr<R>
where R: Eq + Reader,

source§

impl<R> Eq for LocationListEntry<R>
where R: Eq + Reader,

source§

impl<R> Eq for Expression<R>
where R: Eq + Reader,

source§

impl<R> Eq for Attribute<R>
where R: Eq + Reader,

source§

impl<R, A> Eq for UnwindContext<R, A>
where R: Eq + Reader, A: Eq + UnwindContextStorage<R>, <A as UnwindContextStorage<R>>::Stack: Eq,

source§

impl<R, Offset> Eq for LineInstruction<R, Offset>
where R: Eq + Reader<Offset = Offset>, Offset: Eq + ReaderOffset,

source§

impl<R, Offset> Eq for Operation<R, Offset>
where R: Eq + Reader<Offset = Offset>, Offset: Eq + ReaderOffset,

source§

impl<R, Offset> Eq for AttributeValue<R, Offset>
where R: Eq + Reader<Offset = Offset>, Offset: Eq + ReaderOffset,

source§

impl<R, Offset> Eq for ArangeHeader<R, Offset>
where R: Eq + Reader<Offset = Offset>, Offset: Eq + ReaderOffset,

source§

impl<R, Offset> Eq for CommonInformationEntry<R, Offset>
where R: Eq + Reader<Offset = Offset>, Offset: Eq + ReaderOffset,

source§

impl<R, Offset> Eq for FrameDescriptionEntry<R, Offset>
where R: Eq + Reader<Offset = Offset>, Offset: Eq + ReaderOffset,

source§

impl<R, Offset> Eq for CompleteLineProgram<R, Offset>
where R: Eq + Reader<Offset = Offset>, Offset: Eq + ReaderOffset,

source§

impl<R, Offset> Eq for FileEntry<R, Offset>
where R: Eq + Reader<Offset = Offset>, Offset: Eq + ReaderOffset,

source§

impl<R, Offset> Eq for IncompleteLineProgram<R, Offset>
where R: Eq + Reader<Offset = Offset>, Offset: Eq + ReaderOffset,

source§

impl<R, Offset> Eq for LineProgramHeader<R, Offset>
where R: Eq + Reader<Offset = Offset>, Offset: Eq + ReaderOffset,

source§

impl<R, Offset> Eq for UnitHeader<R, Offset>
where R: Eq + Reader<Offset = Offset>, Offset: Eq + ReaderOffset,

source§

impl<R, S> Eq for UnwindTableRow<R, S>
where R: Eq + Reader, S: Eq + UnwindContextStorage<R>,

1.17.0 · source§

impl<T> Eq for Bound<T>
where T: Eq,

source§

impl<T> Eq for Option<T>
where T: Eq,

1.36.0 · source§

impl<T> Eq for Poll<T>
where T: Eq,

source§

impl<T> Eq for UnitSectionOffset<T>
where T: Eq,

source§

impl<T> Eq for DieReference<T>
where T: Eq,

source§

impl<T> Eq for *const T
where T: ?Sized,

source§

impl<T> Eq for *mut T
where T: ?Sized,

source§

impl<T> Eq for [T]
where T: Eq,

source§

impl<T> Eq for (T₁, T₂, …, Tₙ)
where T: Eq + ?Sized,

This trait is implemented for tuples up to twelve items long.

1.2.0 · source§

impl<T> Eq for Cell<T>
where T: Eq + Copy,

1.70.0 · source§

impl<T> Eq for OnceCell<T>
where T: Eq,

1.2.0 · source§

impl<T> Eq for RefCell<T>
where T: Eq + ?Sized,

source§

impl<T> Eq for PhantomData<T>
where T: ?Sized,

1.21.0 · source§

impl<T> Eq for Discriminant<T>

1.20.0 · source§

impl<T> Eq for ManuallyDrop<T>
where T: Eq + ?Sized,

1.28.0 · source§

impl<T> Eq for NonZero<T>
where T: ZeroablePrimitive + Eq,

1.74.0 · source§

impl<T> Eq for Saturating<T>
where T: Eq,

source§

impl<T> Eq for Wrapping<T>
where T: Eq,

1.25.0 · source§

impl<T> Eq for NonNull<T>
where T: ?Sized,

source§

impl<T> Eq for DebugAbbrevOffset<T>
where T: Eq,

source§

impl<T> Eq for DebugAddrBase<T>
where T: Eq,

source§

impl<T> Eq for DebugAddrIndex<T>
where T: Eq,

source§

impl<T> Eq for DebugArangesOffset<T>
where T: Eq,

source§

impl<T> Eq for DebugFrameOffset<T>
where T: Eq,

source§

impl<T> Eq for DebugInfoOffset<T>
where T: Eq,

source§

impl<T> Eq for DebugLineOffset<T>
where T: Eq,

source§

impl<T> Eq for DebugLineStrOffset<T>
where T: Eq,

source§

impl<T> Eq for DebugLocListsBase<T>
where T: Eq,

source§

impl<T> Eq for DebugLocListsIndex<T>
where T: Eq,

source§

impl<T> Eq for DebugMacinfoOffset<T>
where T: Eq,

source§

impl<T> Eq for DebugMacroOffset<T>
where T: Eq,

source§

impl<T> Eq for DebugRngListsBase<T>
where T: Eq,

source§

impl<T> Eq for DebugRngListsIndex<T>
where T: Eq,

source§

impl<T> Eq for DebugStrOffset<T>
where T: Eq,

source§

impl<T> Eq for DebugStrOffsetsBase<T>
where T: Eq,

source§

impl<T> Eq for DebugStrOffsetsIndex<T>
where T: Eq,

source§

impl<T> Eq for DebugTypesOffset<T>
where T: Eq,

source§

impl<T> Eq for EhFrameOffset<T>
where T: Eq,

source§

impl<T> Eq for LocationListsOffset<T>
where T: Eq,

source§

impl<T> Eq for RangeListsOffset<T>
where T: Eq,

source§

impl<T> Eq for RawRangeListsOffset<T>
where T: Eq,

source§

impl<T> Eq for UnitOffset<T>
where T: Eq,

1.19.0 · source§

impl<T> Eq for Reverse<T>
where T: Eq,

source§

impl<T, A> Eq for Box<T, A>
where T: Eq + ?Sized, A: Allocator,

source§

impl<T, A> Eq for BTreeSet<T, A>
where T: Eq, A: Allocator + Clone,

source§

impl<T, A> Eq for LinkedList<T, A>
where T: Eq, A: Allocator,

source§

impl<T, A> Eq for VecDeque<T, A>
where T: Eq, A: Allocator,

source§

impl<T, A> Eq for Rc<T, A>
where T: Eq + ?Sized, A: Allocator,

source§

impl<T, A> Eq for Arc<T, A>
where T: Eq + ?Sized, A: Allocator,

source§

impl<T, A> Eq for Vec<T, A>
where T: Eq, A: Allocator,

source§

impl<T, E> Eq for Result<T, E>
where T: Eq, E: Eq,

source§

impl<T, S> Eq for HashSet<T, S>
where T: Eq + Hash, S: BuildHasher,

source§

impl<T, const N: usize> Eq for [T; N]
where T: Eq,

source§

impl<T, const N: usize> Eq for Simd<T, N>

source§

impl<T: Eq> Eq for TrySendError<T>

source§

impl<T: Eq> Eq for Cursor<T>

source§

impl<T: Eq> Eq for SendError<T>

1.70.0 · source§

impl<T: Eq> Eq for OnceLock<T>

source§

impl<Y, R> Eq for CoroutineState<Y, R>
where Y: Eq, R: Eq,