pub trait Eq: PartialEq { }
std
only.Expand description
Trait for comparisons corresponding to equivalence relations.
The primary difference to PartialEq
is the additional requirement for reflexivity. A type
that implements PartialEq
guarantees that for all a
, b
and c
:
- symmetric:
a == b
impliesb == a
anda != b
implies!(a == b)
- transitive:
a == b
andb == c
impliesa == c
Eq
, which builds on top of PartialEq
also implies:
- reflexive:
a == a
This property cannot be checked by the compiler, and therefore Eq
is a trait without 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.
Floating point types such as f32
and f64
implement only PartialEq
but not Eq
because NaN
!= NaN
.
§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
extra 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 {}
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementors§
impl Eq for RelocationKind
impl Eq for RelocationTarget
impl Eq for CustomSectionProtection
impl Eq for Symbol
impl Eq for CpuFeature
impl Eq for CompiledFunctionUnwindInfo
impl Eq for Aarch64Architecture
impl Eq for Architecture
impl Eq for BinaryFormat
impl Eq for CallingConvention
impl Eq for Endianness
impl Eq for Environment
impl Eq for ExportIndex
impl Eq for ExternType
impl Eq for HashAlgorithm
impl Eq for ImportIndex
impl Eq for LibCall
impl Eq for MemoryStyle
impl Eq for ModuleHash
impl Eq for Mutability
impl Eq for OperatingSystem
impl Eq for PointerWidth
impl Eq for TableStyle
impl Eq for TrapCode
impl Eq for Type
impl Eq for Vendor
impl Eq for MemoryError
impl Eq for Infallible
impl Eq for wasmer_types::lib::std::fmt::Alignment
impl Eq for wasmer_types::lib::std::sync::atomic::Ordering
impl Eq for RecvTimeoutError
impl Eq for TryRecvError
impl Eq for wasmer_types::lib::std::cmp::Ordering
impl Eq for TryReserveErrorKind
impl Eq for AsciiChar
impl Eq for IpAddr
impl Eq for Ipv6MulticastScope
impl Eq for SocketAddr
impl Eq for FpCategory
impl Eq for IntErrorKind
impl Eq for SearchStep
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 hashbrown::TryReserveError
impl Eq for hashbrown::TryReserveError
impl Eq for Panic
impl Eq for ArchivedIpAddr
impl Eq for ArchivedSocketAddr
impl Eq for CDataModel
impl Eq for Size
impl Eq for ParseError
impl Eq for ArmArchitecture
impl Eq for CustomVendor
impl Eq for Mips32Architecture
impl Eq for Mips64Architecture
impl Eq for Riscv32Architecture
impl Eq for Riscv64Architecture
impl Eq for X86_32Architecture
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 FunctionAddressMap
impl Eq for InstructionAddressMap
impl Eq for Compilation
impl Eq for CompiledFunction
impl Eq for CompiledFunctionFrameInfo
impl Eq for Dwarf
impl Eq for FunctionBody
impl Eq for CompileModuleInfo
impl Eq for Relocation
impl Eq for CustomSection
impl Eq for SectionBody
impl Eq for SectionIndex
impl Eq for Target
impl Eq for wasmer_types::Bytes
impl Eq for CustomSectionIndex
impl Eq for DataIndex
impl Eq for DataInitializerLocation
impl Eq for ElemIndex
impl Eq for Features
impl Eq for FunctionIndex
impl Eq for FunctionType
impl Eq for GlobalIndex
impl Eq for GlobalType
impl Eq for ImportKey
impl Eq for LocalFunctionIndex
impl Eq for LocalGlobalIndex
impl Eq for LocalMemoryIndex
impl Eq for LocalTableIndex
impl Eq for MemoryIndex
impl Eq for MemoryType
impl Eq for ModuleInfo
impl Eq for OwnedDataInitializer
impl Eq for PageCountOutOfRange
impl Eq for Pages
impl Eq for SignatureIndex
impl Eq for SourceLoc
impl Eq for StoreId
impl Eq for TableIndex
impl Eq for TableInitializer
impl Eq for TableType
impl Eq for TrapInformation
impl Eq for Triple
impl Eq for V128
impl Eq for TypeId
impl Eq for wasmer_types::lib::std::fmt::Error
impl Eq for PhantomPinned
impl Eq for Assume
impl Eq for RangeFull
impl Eq for wasmer_types::lib::std::ptr::Alignment
impl Eq for FromUtf8Error
impl Eq for String
impl Eq for RecvError
impl Eq for WaitTimeoutResult
impl Eq for UnorderedKeyError
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 Layout
impl Eq for LayoutError
impl Eq for AllocError
impl Eq for CharTryFromError
impl Eq for ParseCharError
impl Eq for DecodeUtf16Error
impl Eq for TryFromCharError
impl Eq for CpuidResult
impl Eq for CStr
impl Eq for FromBytesUntilNulError
impl Eq for FromBytesWithNulError
impl Eq for Ipv4Addr
impl Eq for Ipv6Addr
impl Eq for AddrParseError
impl Eq for SocketAddrV4
impl Eq for SocketAddrV6
impl Eq for ParseFloatError
impl Eq for ParseIntError
impl Eq for TryFromIntError
impl Eq for ParseBoolError
impl Eq for core::str::error::Utf8Error
impl Eq for Duration
impl Eq for TryFromFloatSecsError
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 AccessError
impl Eq for ThreadId
impl Eq for Instant
impl Eq for SystemTime
impl Eq for block_buffer::Error
impl Eq for bytes::bytes::Bytes
impl Eq for BytesMut
impl Eq for InvalidLength
impl Eq for InvalidBufferSize
impl Eq for indexmap::TryReserveError
impl Eq for Failure
impl Eq for NonZeroI16_be
impl Eq for NonZeroI16_le
impl Eq for NonZeroI32_be
impl Eq for NonZeroI32_le
impl Eq for NonZeroI64_be
impl Eq for NonZeroI64_le
impl Eq for NonZeroI128_be
impl Eq for NonZeroI128_le
impl Eq for NonZeroU16_be
impl Eq for NonZeroU16_le
impl Eq for NonZeroU32_be
impl Eq for NonZeroU32_le
impl Eq for NonZeroU64_be
impl Eq for NonZeroU64_le
impl Eq for NonZeroU128_be
impl Eq for NonZeroU128_le
impl Eq for char_be
impl Eq for char_le
impl Eq for f32_be
impl Eq for f32_le
impl Eq for f64_be
impl Eq for f64_le
impl Eq for i16_be
impl Eq for i16_le
impl Eq for i32_be
impl Eq for i32_le
impl Eq for i64_be
impl Eq for i64_le
impl Eq for i128_be
impl Eq for i128_le
impl Eq for u16_be
impl Eq for u16_le
impl Eq for u32_be
impl Eq for u32_le
impl Eq for u64_be
impl Eq for u64_le
impl Eq for u128_be
impl Eq for u128_le
impl Eq for NonZeroI16_ube
impl Eq for NonZeroI16_ule
impl Eq for NonZeroI32_ube
impl Eq for NonZeroI32_ule
impl Eq for NonZeroI64_ube
impl Eq for NonZeroI64_ule
impl Eq for NonZeroI128_ube
impl Eq for NonZeroI128_ule
impl Eq for NonZeroU16_ube
impl Eq for NonZeroU16_ule
impl Eq for NonZeroU32_ube
impl Eq for NonZeroU32_ule
impl Eq for NonZeroU64_ube
impl Eq for NonZeroU64_ule
impl Eq for NonZeroU128_ube
impl Eq for NonZeroU128_ule
impl Eq for char_ube
impl Eq for char_ule
impl Eq for f32_ube
impl Eq for f32_ule
impl Eq for f64_ube
impl Eq for f64_ule
impl Eq for i16_ube
impl Eq for i16_ule
impl Eq for i32_ube
impl Eq for i32_ule
impl Eq for i64_ube
impl Eq for i64_ule
impl Eq for i128_ube
impl Eq for i128_ule
impl Eq for u16_ube
impl Eq for u16_ule
impl Eq for u32_ube
impl Eq for u32_ule
impl Eq for u64_ube
impl Eq for u64_ule
impl Eq for u128_ube
impl Eq for u128_ule
impl Eq for ArchivedCString
impl Eq for ArchivedIpv4Addr
impl Eq for ArchivedIpv6Addr
impl Eq for ArchivedSocketAddrV4
impl Eq for ArchivedSocketAddrV6
impl Eq for ArchivedOptionNonZeroI8
impl Eq for ArchivedOptionNonZeroI16
impl Eq for ArchivedOptionNonZeroI32
impl Eq for ArchivedOptionNonZeroI64
impl Eq for ArchivedOptionNonZeroI128
impl Eq for ArchivedOptionNonZeroU8
impl Eq for ArchivedOptionNonZeroU16
impl Eq for ArchivedOptionNonZeroU32
impl Eq for ArchivedOptionNonZeroU64
impl Eq for ArchivedOptionNonZeroU128
impl Eq for ArchivedRangeFull
impl Eq for ArchivedString
impl Eq for ArchivedDuration
impl Eq for simdutf8::basic::Utf8Error
impl Eq for simdutf8::compat::Utf8Error
impl Eq for DefaultToHost
impl Eq for DefaultToUnknown
impl Eq for ATerm
impl Eq for B0
impl Eq for B1
impl Eq for Z0
impl Eq for Equal
impl Eq for Greater
impl Eq for Less
impl Eq for UTerm
impl<'a> Eq for CompiledFunctionUnwindInfoReference<'a>
impl<'a> Eq for Utf8Pattern<'a>
impl<'a> Eq for Component<'a>
impl<'a> Eq for Prefix<'a>
impl<'a> Eq for Location<'a>
impl<'a> Eq for Utf8Chunk<'a>
impl<'a> Eq for PrefixComponent<'a>
impl<A> Eq for &A
impl<A> Eq for &mut A
impl<B> Eq for Cow<'_, B>
impl<B, C> Eq for ControlFlow<B, C>
impl<Dyn> Eq for wasmer_types::lib::std::ptr::DynMetadata<Dyn>where
Dyn: ?Sized,
impl<Dyn> Eq for ptr_meta::DynMetadata<Dyn>where
Dyn: ?Sized,
impl<F> Eq for Fwhere
F: FnPtr,
impl<H> Eq for BuildHasherDefault<H>
impl<Idx> Eq for wasmer_types::lib::std::ops::Range<Idx>where
Idx: Eq,
impl<Idx> Eq for wasmer_types::lib::std::ops::RangeFrom<Idx>where
Idx: Eq,
impl<Idx> Eq for wasmer_types::lib::std::ops::RangeInclusive<Idx>where
Idx: Eq,
impl<Idx> Eq for RangeTo<Idx>where
Idx: Eq,
impl<Idx> Eq for RangeToInclusive<Idx>where
Idx: Eq,
impl<Idx> Eq for core::range::Range<Idx>where
Idx: Eq,
impl<Idx> Eq for core::range::RangeFrom<Idx>where
Idx: Eq,
impl<Idx> Eq for core::range::RangeInclusive<Idx>where
Idx: Eq,
impl<K, H> Eq for ArchivedIndexSet<K, H>where
K: Eq,
impl<K, H> Eq for ArchivedHashSet<K, H>
impl<K, V> Eq for SecondaryMap<K, V>
impl<K, V> Eq for indexmap::map::slice::Slice<K, V>
impl<K, V> Eq for Entry<K, V>
impl<K, V, A> Eq for BTreeMap<K, V, A>
impl<K, V, H> Eq for ArchivedIndexMap<K, V, H>
impl<K, V, H> Eq for ArchivedHashMap<K, V, H>
impl<K, V, S> Eq for std::collections::hash::map::HashMap<K, V, S>
impl<K, V, S> Eq for IndexMap<K, V, S>
impl<K, V, S, A> Eq for hashbrown::map::HashMap<K, V, S, A>
impl<K, V, S, A> Eq for hashbrown::map::HashMap<K, V, S, A>
impl<K, V, const E: usize> Eq for ArchivedBTreeMap<K, V, E>
alloc
only.impl<K, V: Eq> Eq for PrimaryMap<K, V>
impl<Ptr> Eq for Pin<Ptr>
impl<T0> Eq for ArchivedTuple1<T0>where
T0: Eq,
impl<T0, T1> Eq for ArchivedTuple2<T0, T1>
impl<T0, T1, T2> Eq for ArchivedTuple3<T0, T1, T2>
impl<T0, T1, T2, T3> Eq for ArchivedTuple4<T0, T1, T2, T3>
impl<T0, T1, T2, T3, T4> Eq for ArchivedTuple5<T0, T1, T2, T3, T4>
impl<T0, T1, T2, T3, T4, T5> Eq for ArchivedTuple6<T0, T1, T2, T3, T4, T5>
impl<T0, T1, T2, T3, T4, T5, T6> Eq for ArchivedTuple7<T0, T1, T2, T3, T4, T5, T6>
impl<T0, T1, T2, T3, T4, T5, T6, T7> Eq for ArchivedTuple8<T0, T1, T2, T3, T4, T5, T6, T7>
impl<T0, T1, T2, T3, T4, T5, T6, T7, T8> Eq for ArchivedTuple9<T0, T1, T2, T3, T4, T5, T6, T7, T8>
impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> Eq for ArchivedTuple10<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9>
impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> Eq for ArchivedTuple11<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>
impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Eq for ArchivedTuple12<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>
impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Eq for ArchivedTuple13<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>
impl<T> Eq for Bound<T>where
T: Eq,
impl<T> Eq for SendTimeoutError<T>where
T: Eq,
impl<T> Eq for TrySendError<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 ArchivedBound<T>where
T: Eq,
impl<T> Eq for ArchivedOption<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ₙ)
This trait is implemented for tuples up to twelve items long.