pub trait Eq: PartialEq<Self> { }
Expand description
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: &Self) -> bool {
self.isbn == other.isbn
}
}
impl Eq for Book {}
Implementors§
impl Eq for EntityIndex
impl Eq for FlagValue
impl Eq for GlobalInit
impl Eq for Trap
impl Eq for WasmType
impl Eq for BlockType
impl Eq for CanonicalOption
impl Eq for ComponentExternalKind
impl Eq for ComponentOuterAliasKind
impl Eq for ComponentTypeRef
impl Eq for ComponentValType
impl Eq for wasmtime_environ::wasmparser::Encoding
impl Eq for ExternalKind
impl Eq for FrameKind
impl Eq for InstantiationArgKind
impl Eq for OuterAliasKind
impl Eq for PrimitiveValType
impl Eq for TypeBounds
impl Eq for ValType
impl Eq for wasmtime_environ::__core::cmp::Ordering
impl Eq for Infallible
impl Eq for wasmtime_environ::__core::fmt::Alignment
impl Eq for IpAddr
impl Eq for Ipv6MulticastScope
impl Eq for SocketAddr
impl Eq for FpCategory
impl Eq for IntErrorKind
impl Eq for Which
impl Eq for SearchStep
impl Eq for wasmtime_environ::__core::sync::atomic::Ordering
impl Eq for TryReserveErrorKind
impl Eq for BacktraceStatus
impl Eq for VarError
impl Eq for SeekFrom
impl Eq for ErrorKind
impl Eq for Shutdown
impl Eq for BacktraceStyle
impl Eq for RecvTimeoutError
impl Eq for TryRecvError
impl Eq for DwarfFileType
impl Eq for Format
impl Eq for gimli::common::SectionId
impl Eq for RunTimeEndian
impl Eq for Pointer
impl Eq for gimli::read::Error
impl Eq for ColumnType
impl Eq for ValueType
impl Eq for log::Level
impl Eq for LevelFilter
impl Eq for AddressSize
impl Eq for object::common::Architecture
impl Eq for object::common::BinaryFormat
impl Eq for ComdatKind
impl Eq for FileFlags
impl Eq for RelocationEncoding
impl Eq for RelocationKind
impl Eq for SectionFlags
impl Eq for SectionKind
impl Eq for SegmentFlags
impl Eq for SymbolKind
impl Eq for SymbolScope
impl Eq for object::endian::Endianness
impl Eq for CompressionFormat
impl Eq for FileKind
impl Eq for ObjectKind
impl Eq for RelocationTarget
impl Eq for object::read::SymbolSection
impl Eq for Mangling
impl Eq for StandardSection
impl Eq for StandardSegment
impl Eq for object::write::SymbolSection
impl Eq for CDataModel
impl Eq for Size
impl Eq for target_lexicon::parse_error::ParseError
impl Eq for Aarch64Architecture
impl Eq for target_lexicon::targets::Architecture
impl Eq for ArmArchitecture
impl Eq for target_lexicon::targets::BinaryFormat
impl Eq for CustomVendor
impl Eq for Environment
impl Eq for Mips32Architecture
impl Eq for Mips64Architecture
impl Eq for OperatingSystem
impl Eq for Riscv32Architecture
impl Eq for Riscv64Architecture
impl Eq for Vendor
impl Eq for X86_32Architecture
impl Eq for CallingConvention
impl Eq for target_lexicon::triple::Endianness
impl Eq for PointerWidth
impl Eq for Origin
impl Eq for url::parser::ParseError
impl Eq for SyntaxViolation
impl Eq for bool
impl Eq for char
impl Eq for i8
impl Eq for i16
impl Eq for i32
impl Eq for i64
impl Eq for i128
impl Eq for isize
impl Eq for !
impl Eq for str
impl Eq for u8
impl Eq for u16
impl Eq for u32
impl Eq for u64
impl Eq for u128
impl Eq for ()
impl Eq for usize
impl Eq for AnyfuncIndex
impl Eq for DataIndex
impl Eq for DefinedFuncIndex
impl Eq for DefinedGlobalIndex
impl Eq for DefinedMemoryIndex
impl Eq for DefinedTableIndex
impl Eq for ElemIndex
impl Eq for FilePos
impl Eq for FuncIndex
impl Eq for Global
impl Eq for GlobalIndex
impl Eq for InstructionAddressMap
impl Eq for Memory
impl Eq for MemoryIndex
impl Eq for OwnedMemoryIndex
impl Eq for SignatureIndex
impl Eq for Table
impl Eq for TableIndex
impl Eq for Tag
impl Eq for TagIndex
impl Eq for TrapInformation
impl Eq for TypeIndex
impl Eq for WasmFuncType
impl Eq for FuncType
impl Eq for GlobalType
impl Eq for Ieee32
impl Eq for Ieee64
impl Eq for MemoryType
impl Eq for TableType
impl Eq for V128
impl Eq for KebabStr
impl Eq for KebabString
impl Eq for wasmtime_environ::wasmparser::types::TypeId
impl Eq for AllocError
impl Eq for Layout
impl Eq for LayoutError
impl Eq for wasmtime_environ::__core::any::TypeId
impl Eq for CpuidResult
impl Eq for CharTryFromError
impl Eq for DecodeUtf16Error
impl Eq for ParseCharError
impl Eq for TryFromCharError
impl Eq for CStr
impl Eq for FromBytesUntilNulError
impl Eq for FromBytesWithNulError
impl Eq for wasmtime_environ::__core::fmt::Error
impl Eq for PhantomPinned
impl Eq for Assume
impl Eq for AddrParseError
impl Eq for Ipv4Addr
impl Eq for Ipv6Addr
impl Eq for SocketAddrV4
impl Eq for SocketAddrV6
impl Eq for NonZeroI8
impl Eq for NonZeroI16
impl Eq for NonZeroI32
impl Eq for NonZeroI64
impl Eq for NonZeroI128
impl Eq for NonZeroIsize
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 Eq for ParseFloatError
impl Eq for ParseIntError
impl Eq for TryFromIntError
impl Eq for RangeFull
impl Eq for wasmtime_environ::__core::ptr::Alignment
impl Eq for ParseBoolError
impl Eq for Utf8Error
impl Eq for Duration
impl Eq for TryFromFloatSecsError
impl Eq for alloc::collections::TryReserveError
impl Eq for CString
impl Eq for FromVecWithNulError
impl Eq for IntoStringError
impl Eq for NulError
impl Eq for FromUtf8Error
impl Eq for String
impl Eq for OsStr
impl Eq for OsString
impl Eq for FileType
impl Eq for Permissions
impl Eq for UCred
impl Eq for Components<'_>
impl Eq for Path
impl Eq for PathBuf
impl Eq for StripPrefixError
impl Eq for ExitStatus
impl Eq for ExitStatusError
impl Eq for Output
impl Eq for WaitTimeoutResult
impl Eq for RecvError
impl Eq for AccessError
impl Eq for ThreadId
impl Eq for Instant
impl Eq for SystemTime
impl Eq for getrandom::error::Error
impl Eq for DebugTypeSignature
impl Eq for DwoId
impl Eq for gimli::common::Encoding
impl Eq for LineEncoding
impl Eq for Register
impl Eq for DwAccess
impl Eq for DwAddr
impl Eq for DwAt
impl Eq for DwAte
impl Eq for DwCc
impl Eq for DwCfa
impl Eq for DwChildren
impl Eq for DwDefaulted
impl Eq for DwDs
impl Eq for DwDsc
impl Eq for DwEhPe
impl Eq for DwEnd
impl Eq for DwForm
impl Eq for DwId
impl Eq for DwIdx
impl Eq for DwInl
impl Eq for DwLang
impl Eq for DwLle
impl Eq for DwLnct
impl Eq for DwLne
impl Eq for DwLns
impl Eq for DwMacro
impl Eq for DwOp
impl Eq for DwOrd
impl Eq for DwRle
impl Eq for DwSect
impl Eq for DwSectV2
impl Eq for DwTag
impl Eq for DwUt
impl Eq for DwVirtuality
impl Eq for DwVis
impl Eq for gimli::endianity::BigEndian
impl Eq for gimli::endianity::LittleEndian
impl Eq for Abbreviation
impl Eq for AttributeSpecification
impl Eq for ArangeEntry
impl Eq for Augmentation
impl Eq for BaseAddresses
impl Eq for SectionBaseAddresses
impl Eq for UnitIndexSection
impl Eq for FileEntryFormat
impl Eq for LineRow
impl Eq for ReaderOffsetId
impl Eq for gimli::read::rnglists::Range
impl Eq for StoreOnHeap
impl Eq for object::endian::BigEndian
impl Eq for object::endian::LittleEndian
impl Eq for CompressedFileRange
impl Eq for object::read::Error
impl Eq for object::read::SectionIndex
impl Eq for object::read::SymbolIndex
impl Eq for object::write::elf::writer::SectionIndex
impl Eq for object::write::elf::writer::SymbolIndex
impl Eq for StringId
impl Eq for ComdatId
impl Eq for object::write::Error
impl Eq for object::write::SectionId
impl Eq for SymbolId
impl Eq for DefaultToHost
impl Eq for DefaultToUnknown
impl Eq for Triple
impl Eq for OpaqueOrigin
impl Eq for Url
URLs compare like their serialization.
impl Eq for BidiClass
impl Eq for IsNormalized
impl Eq for Level
impl Eq for TryReserveError
impl<'a> Eq for ComponentDefinedType<'a>
impl<'a> Eq for Component<'a>
impl<'a> Eq for Prefix<'a>
impl<'a> Eq for VariantCase<'a>
impl<'a> Eq for Location<'a>
impl<'a> Eq for Utf8Chunk<'a>
impl<'a> Eq for PrefixComponent<'a>
impl<'a> Eq for Metadata<'a>
impl<'a> Eq for MetadataBuilder<'a>
impl<'bases, Section, R> Eq for CieOrFde<'bases, Section, R>where Section: Eq + UnwindSection<R>, R: Eq + Reader,
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,
impl<'data> Eq for CodeView<'data>
impl<'data> Eq for CompressedData<'data>
impl<'data> Eq for Export<'data>
impl<'data> Eq for Import<'data>
impl<'data> Eq for ObjectMapEntry<'data>
impl<'data> Eq for SymbolMapName<'data>
impl<'data> Eq for Bytes<'data>
impl<'input, Endian> Eq for EndianSlice<'input, Endian>where Endian: Eq + Endianity,
impl<'s, T> Eq for SliceVec<'s, T>where T: Eq,
impl<A> Eq for &Awhere A: Eq + ?Sized,
impl<A> Eq for &mut Awhere A: Eq + ?Sized,
impl<A> Eq for ArrayVec<A>where A: Array, <A as Array>::Item: Eq,
impl<A> Eq for TinyVec<A>where A: Array, <A as Array>::Item: Eq,
impl<B> Eq for Cow<'_, B>where B: Eq + ToOwned + ?Sized,
impl<B, C> Eq for ControlFlow<B, C>where B: Eq, C: Eq,
impl<Dyn> Eq for DynMetadata<Dyn>where Dyn: ?Sized,
impl<E> Eq for I16<E>where E: Eq + Endian,
impl<E> Eq for I32<E>where E: Eq + Endian,
impl<E> Eq for I64<E>where E: Eq + Endian,
impl<E> Eq for U16<E>where E: Eq + Endian,
impl<E> Eq for U32<E>where E: Eq + Endian,
impl<E> Eq for U64<E>where E: Eq + Endian,
impl<E> Eq for I16Bytes<E>where E: Eq + Endian,
impl<E> Eq for I32Bytes<E>where E: Eq + Endian,
impl<E> Eq for I64Bytes<E>where E: Eq + Endian,
impl<E> Eq for U16Bytes<E>where E: Eq + Endian,
impl<E> Eq for U32Bytes<E>where E: Eq + Endian,
impl<E> Eq for U64Bytes<E>where E: Eq + Endian,
impl<H> Eq for BuildHasherDefault<H>
impl<Idx> Eq for wasmtime_environ::__core::ops::Range<Idx>where Idx: Eq,
impl<Idx> Eq for RangeFrom<Idx>where Idx: Eq,
impl<Idx> Eq for RangeInclusive<Idx>where Idx: Eq,
impl<Idx> Eq for RangeTo<Idx>where Idx: Eq,
impl<Idx> Eq for RangeToInclusive<Idx>where Idx: Eq,
impl<K, V> Eq for PrimaryMap<K, V>where K: Eq + EntityRef, V: Eq,
impl<K, V> Eq for SecondaryMap<K, V>where K: EntityRef, V: Clone + PartialEq<V> + Eq,
impl<K, V, A> Eq for BTreeMap<K, V, A>where K: Eq, V: Eq, A: Allocator + Clone,
impl<K, V, S> Eq for std::collections::hash::map::HashMap<K, V, S>where K: Eq + Hash, V: Eq, S: BuildHasher,
impl<K, V, S> Eq for IndexMap<K, V, S>where K: Eq + Hash, V: Eq, S: BuildHasher,
impl<K, V, S, A> Eq for HashMap<K, V, S, A>where K: Eq + Hash, V: Eq, S: BuildHasher, A: Allocator + Clone,
impl<Offset> Eq for UnitType<Offset>where Offset: Eq + ReaderOffset,
impl<P> Eq for Pin<P>where P: Deref, <P as Deref>::Target: Eq,
impl<R> Eq for CallFrameInstruction<R>where R: Eq + Reader,
impl<R> Eq for CfaRule<R>where R: Eq + Reader,
impl<R> Eq for RegisterRule<R>where R: Eq + Reader,
impl<R> Eq for DebugFrame<R>where R: Eq + Reader,
impl<R> Eq for EhFrame<R>where R: Eq + Reader,
impl<R> Eq for EhFrameHdr<R>where R: Eq + Reader,
impl<R> Eq for LocationListEntry<R>where R: Eq + Reader,
impl<R> Eq for Expression<R>where R: Eq + Reader,
impl<R> Eq for Attribute<R>where R: Eq + Reader,
impl<R, A> Eq for UnwindContext<R, A>where R: Eq + Reader, A: Eq + UnwindContextStorage<R>, <A as UnwindContextStorage<R>>::Stack: Eq,
impl<R, Offset> Eq for LineInstruction<R, Offset>where R: Eq + Reader<Offset = Offset>, Offset: Eq + ReaderOffset,
impl<R, Offset> Eq for Operation<R, Offset>where R: Eq + Reader<Offset = Offset>, Offset: Eq + ReaderOffset,
impl<R, Offset> Eq for AttributeValue<R, Offset>where R: Eq + Reader<Offset = Offset>, Offset: Eq + ReaderOffset,
impl<R, Offset> Eq for ArangeHeader<R, Offset>where R: Eq + Reader<Offset = Offset>, Offset: Eq + ReaderOffset,
impl<R, Offset> Eq for CommonInformationEntry<R, Offset>where R: Eq + Reader<Offset = Offset>, Offset: Eq + ReaderOffset,
impl<R, Offset> Eq for FrameDescriptionEntry<R, Offset>where R: Eq + Reader<Offset = Offset>, Offset: Eq + ReaderOffset,
impl<R, Offset> Eq for CompleteLineProgram<R, Offset>where R: Eq + Reader<Offset = Offset>, Offset: Eq + ReaderOffset,
impl<R, Offset> Eq for FileEntry<R, Offset>where R: Eq + Reader<Offset = Offset>, Offset: Eq + ReaderOffset,
impl<R, Offset> Eq for IncompleteLineProgram<R, Offset>where R: Eq + Reader<Offset = Offset>, Offset: Eq + ReaderOffset,
impl<R, Offset> Eq for LineProgramHeader<R, Offset>where R: Eq + Reader<Offset = Offset>, Offset: Eq + ReaderOffset,
impl<R, Offset> Eq for UnitHeader<R, Offset>where R: Eq + Reader<Offset = Offset>, Offset: Eq + ReaderOffset,
impl<R, S> Eq for UnwindTableRow<R, S>where R: Eq + Reader, S: Eq + UnwindContextStorage<R>,
impl<Ret, T> Eq for fn (T₁, T₂, …, Tₙ) -> Ret
This trait is implemented for function pointers with up to twelve arguments.
impl<Ret, T> Eq for extern "C" fn (T₁, T₂, …, Tₙ) -> Ret
This trait is implemented for function pointers with up to twelve arguments.
impl<Ret, T> Eq for extern "C" fn (T₁, T₂, …, Tₙ, ...) -> Ret
This trait is implemented for function pointers with up to twelve arguments.
impl<Ret, T> Eq for extern "C-unwind" fn (T₁, T₂, …, Tₙ) -> Ret
This trait is implemented for function pointers with up to twelve arguments.
impl<Ret, T> Eq for extern "C-unwind" fn (T₁, T₂, …, Tₙ, ...) -> Ret
This trait is implemented for function pointers with up to twelve arguments.
impl<Ret, T> Eq for unsafe fn (T₁, T₂, …, Tₙ) -> Ret
This trait is implemented for function pointers with up to twelve arguments.
impl<Ret, T> Eq for unsafe extern "C" fn (T₁, T₂, …, Tₙ) -> Ret
This trait is implemented for function pointers with up to twelve arguments.
impl<Ret, T> Eq for unsafe extern "C" fn (T₁, T₂, …, Tₙ, ...) -> Ret
This trait is implemented for function pointers with up to twelve arguments.
impl<Ret, T> Eq for unsafe extern "C-unwind" fn (T₁, T₂, …, Tₙ) -> Ret
This trait is implemented for function pointers with up to twelve arguments.
impl<Ret, T> Eq for unsafe extern "C-unwind" fn (T₁, T₂, …, Tₙ, ...) -> Ret
This trait is implemented for function pointers with up to twelve arguments.
impl<S> Eq for Host<S>where S: Eq,
impl<Section> Eq for SymbolFlags<Section>where Section: Eq,
impl<T> Eq for Bound<T>where T: Eq,
impl<T> Eq for Option<T>where T: Eq,
impl<T> Eq for Poll<T>where T: Eq,
impl<T> Eq for TrySendError<T>where T: Eq,
impl<T> Eq for UnitSectionOffset<T>where T: Eq,
impl<T> Eq for DieReference<T>where T: Eq,
impl<T> Eq for *const Twhere T: ?Sized,
impl<T> Eq for *mut Twhere T: ?Sized,
impl<T> Eq for [T]where T: Eq,
impl<T> Eq for (T₁, T₂, …, Tₙ)where T: Eq + ?Sized,
This trait is implemented for tuples up to twelve items long.