pub trait StructuralEq { }
🔬This is a nightly-only experimental API. (structural_match)
Expand description

Required trait for constants used in pattern matches.

Any type that derives Eq automatically implements this trait, regardless of whether its type parameters implement Eq.

This is a hack to work around a limitation in our type system.

Background

We want to require that types of consts used in pattern matches have the attribute #[derive(PartialEq, Eq)].

In a more ideal world, we could check that requirement by just checking that the given type implements both the StructuralPartialEq trait and the Eq trait. However, you can have ADTs that do derive(PartialEq, Eq), and be a case that we want the compiler to accept, and yet the constant’s type fails to implement Eq.

Namely, a case like this:

#[derive(PartialEq, Eq)]
struct Wrap<X>(X);

fn higher_order(_: &()) { }

const CFN: Wrap<fn(&())> = Wrap(higher_order);

fn main() {
    match CFN {
        CFN => {}
        _ => {}
    }
}

(The problem in the above code is that Wrap<fn(&())> does not implement PartialEq, nor Eq, because for<'a> fn(&'a _) does not implement those traits.)

Therefore, we cannot rely on naive check for StructuralPartialEq and mere Eq.

As a hack to work around this, we use two separate traits injected by each of the two derives (#[derive(PartialEq)] and #[derive(Eq)]) and check that both of them are present as part of structural-match checking.

Implementors§

source§

impl StructuralEq for EntityIndex

source§

impl StructuralEq for FlagValue

source§

impl StructuralEq for GlobalInit

source§

impl StructuralEq for Trap

source§

impl StructuralEq for WasmType

source§

impl StructuralEq for BlockType

source§

impl StructuralEq for CanonicalOption

source§

impl StructuralEq for ComponentExternalKind

source§

impl StructuralEq for ComponentOuterAliasKind

source§

impl StructuralEq for ComponentTypeRef

source§

impl StructuralEq for ComponentValType

source§

impl StructuralEq for wasmtime_environ::wasmparser::Encoding

source§

impl StructuralEq for ExternalKind

source§

impl StructuralEq for FrameKind

source§

impl StructuralEq for InstantiationArgKind

source§

impl StructuralEq for OuterAliasKind

source§

impl StructuralEq for PrimitiveValType

source§

impl StructuralEq for TypeBounds

source§

impl StructuralEq for ValType

1.0.0 · source§

impl StructuralEq for wasmtime_environ::__core::cmp::Ordering

1.28.0 · source§

impl StructuralEq for wasmtime_environ::__core::fmt::Alignment

1.7.0 · source§

impl StructuralEq for IpAddr

source§

impl StructuralEq for Ipv6MulticastScope

1.0.0 · source§

impl StructuralEq for SocketAddr

1.0.0 · source§

impl StructuralEq for FpCategory

1.55.0 · source§

impl StructuralEq for IntErrorKind

source§

impl StructuralEq for Which

source§

impl StructuralEq for SearchStep

1.0.0 · source§

impl StructuralEq for wasmtime_environ::__core::sync::atomic::Ordering

source§

impl StructuralEq for TryReserveErrorKind

1.65.0 · source§

impl StructuralEq for BacktraceStatus

1.0.0 · source§

impl StructuralEq for VarError

1.0.0 · source§

impl StructuralEq for SeekFrom

1.0.0 · source§

impl StructuralEq for ErrorKind

1.0.0 · source§

impl StructuralEq for Shutdown

source§

impl StructuralEq for BacktraceStyle

1.12.0 · source§

impl StructuralEq for RecvTimeoutError

1.0.0 · source§

impl StructuralEq for TryRecvError

source§

impl StructuralEq for DwarfFileType

source§

impl StructuralEq for Format

source§

impl StructuralEq for gimli::common::SectionId

source§

impl StructuralEq for RunTimeEndian

source§

impl StructuralEq for Pointer

source§

impl StructuralEq for gimli::read::Error

source§

impl StructuralEq for ColumnType

source§

impl StructuralEq for ValueType

source§

impl StructuralEq for log::Level

source§

impl StructuralEq for LevelFilter

source§

impl StructuralEq for AddressSize

source§

impl StructuralEq for object::common::Architecture

source§

impl StructuralEq for object::common::BinaryFormat

source§

impl StructuralEq for ComdatKind

source§

impl StructuralEq for FileFlags

source§

impl StructuralEq for RelocationEncoding

source§

impl StructuralEq for RelocationKind

source§

impl StructuralEq for SectionFlags

source§

impl StructuralEq for SectionKind

source§

impl StructuralEq for SegmentFlags

source§

impl StructuralEq for SymbolKind

source§

impl StructuralEq for SymbolScope

source§

impl StructuralEq for object::endian::Endianness

source§

impl StructuralEq for CompressionFormat

source§

impl StructuralEq for FileKind

source§

impl StructuralEq for ObjectKind

source§

impl StructuralEq for RelocationTarget

source§

impl StructuralEq for object::read::SymbolSection

source§

impl StructuralEq for Mangling

source§

impl StructuralEq for StandardSection

source§

impl StructuralEq for StandardSegment

source§

impl StructuralEq for object::write::SymbolSection

source§

impl StructuralEq for CDataModel

source§

impl StructuralEq for Size

source§

impl StructuralEq for target_lexicon::parse_error::ParseError

source§

impl StructuralEq for Aarch64Architecture

source§

impl StructuralEq for target_lexicon::targets::Architecture

source§

impl StructuralEq for ArmArchitecture

source§

impl StructuralEq for target_lexicon::targets::BinaryFormat

source§

impl StructuralEq for CustomVendor

source§

impl StructuralEq for Environment

source§

impl StructuralEq for Mips32Architecture

source§

impl StructuralEq for Mips64Architecture

source§

impl StructuralEq for OperatingSystem

source§

impl StructuralEq for Riscv32Architecture

source§

impl StructuralEq for Riscv64Architecture

source§

impl StructuralEq for Vendor

source§

impl StructuralEq for X86_32Architecture

source§

impl StructuralEq for CallingConvention

source§

impl StructuralEq for target_lexicon::triple::Endianness

source§

impl StructuralEq for PointerWidth

source§

impl StructuralEq for Origin

source§

impl StructuralEq for url::parser::ParseError

source§

impl StructuralEq for SyntaxViolation

source§

impl StructuralEq for AnyfuncIndex

source§

impl StructuralEq for DataIndex

source§

impl StructuralEq for DefinedFuncIndex

source§

impl StructuralEq for DefinedGlobalIndex

source§

impl StructuralEq for DefinedMemoryIndex

source§

impl StructuralEq for DefinedTableIndex

source§

impl StructuralEq for ElemIndex

source§

impl StructuralEq for FilePos

source§

impl StructuralEq for FuncIndex

source§

impl StructuralEq for Global

source§

impl StructuralEq for GlobalIndex

source§

impl StructuralEq for InstructionAddressMap

source§

impl StructuralEq for Memory

source§

impl StructuralEq for MemoryIndex

source§

impl StructuralEq for OwnedMemoryIndex

source§

impl StructuralEq for SignatureIndex

source§

impl StructuralEq for Table

source§

impl StructuralEq for TableIndex

source§

impl StructuralEq for Tag

source§

impl StructuralEq for TagIndex

source§

impl StructuralEq for TrapInformation

source§

impl StructuralEq for TypeIndex

source§

impl StructuralEq for WasmFuncType

source§

impl StructuralEq for FuncType

source§

impl StructuralEq for GlobalType

source§

impl StructuralEq for Ieee32

source§

impl StructuralEq for Ieee64

source§

impl StructuralEq for MemoryType

source§

impl StructuralEq for TableType

source§

impl StructuralEq for V128

source§

impl StructuralEq for KebabStr

source§

impl StructuralEq for KebabString

source§

impl StructuralEq for wasmtime_environ::wasmparser::types::TypeId

source§

impl StructuralEq for AllocError

1.28.0 · source§

impl StructuralEq for Layout

1.50.0 · source§

impl StructuralEq for LayoutError

1.0.0 · source§

impl StructuralEq for wasmtime_environ::__core::any::TypeId

1.27.0 · source§

impl StructuralEq for CpuidResult

1.34.0 · source§

impl StructuralEq for CharTryFromError

1.9.0 · source§

impl StructuralEq for DecodeUtf16Error

1.20.0 · source§

impl StructuralEq for ParseCharError

1.59.0 · source§

impl StructuralEq for TryFromCharError

1.70.0-nightly · source§

impl StructuralEq for FromBytesUntilNulError

1.64.0 · source§

impl StructuralEq for FromBytesWithNulError

1.0.0 · source§

impl StructuralEq for wasmtime_environ::__core::fmt::Error

source§

impl StructuralEq for Assume

1.0.0 · source§

impl StructuralEq for AddrParseError

1.0.0 · source§

impl StructuralEq for Ipv4Addr

1.0.0 · source§

impl StructuralEq for Ipv6Addr

1.0.0 · source§

impl StructuralEq for SocketAddrV4

1.0.0 · source§

impl StructuralEq for SocketAddrV6

1.34.0 · source§

impl StructuralEq for NonZeroI8

1.34.0 · source§

impl StructuralEq for NonZeroI16

1.34.0 · source§

impl StructuralEq for NonZeroI32

1.34.0 · source§

impl StructuralEq for NonZeroI64

1.34.0 · source§

impl StructuralEq for NonZeroI128

1.34.0 · source§

impl StructuralEq for NonZeroIsize

1.28.0 · source§

impl StructuralEq for NonZeroU8

1.28.0 · source§

impl StructuralEq for NonZeroU16

1.28.0 · source§

impl StructuralEq for NonZeroU32

1.28.0 · source§

impl StructuralEq for NonZeroU64

1.28.0 · source§

impl StructuralEq for NonZeroU128

1.28.0 · source§

impl StructuralEq for NonZeroUsize

1.0.0 · source§

impl StructuralEq for ParseFloatError

1.0.0 · source§

impl StructuralEq for ParseIntError

1.34.0 · source§

impl StructuralEq for TryFromIntError

1.0.0 · source§

impl StructuralEq for RangeFull

source§

impl StructuralEq for wasmtime_environ::__core::ptr::Alignment

1.0.0 · source§

impl StructuralEq for ParseBoolError

1.0.0 · source§

impl StructuralEq for Utf8Error

1.3.0 · source§

impl StructuralEq for Duration

1.66.0 · source§

impl StructuralEq for TryFromFloatSecsError

1.57.0 · source§

impl StructuralEq for alloc::collections::TryReserveError

1.64.0 · source§

impl StructuralEq for CString

1.64.0 · source§

impl StructuralEq for FromVecWithNulError

1.64.0 · source§

impl StructuralEq for IntoStringError

1.64.0 · source§

impl StructuralEq for NulError

1.0.0 · source§

impl StructuralEq for FromUtf8Error

1.0.0 · source§

impl StructuralEq for String

1.1.0 · source§

impl StructuralEq for FileType

1.0.0 · source§

impl StructuralEq for Permissions

1.63.0 · source§

impl StructuralEq for InvalidHandleError

1.63.0 · source§

impl StructuralEq for NullHandleError

1.7.0 · source§

impl StructuralEq for StripPrefixError

1.0.0 · source§

impl StructuralEq for ExitStatus

source§

impl StructuralEq for ExitStatusError

1.0.0 · source§

impl StructuralEq for Output

1.5.0 · source§

impl StructuralEq for WaitTimeoutResult

1.0.0 · source§

impl StructuralEq for RecvError

1.26.0 · source§

impl StructuralEq for AccessError

1.19.0 · source§

impl StructuralEq for ThreadId

1.8.0 · source§

impl StructuralEq for Instant

1.8.0 · source§

impl StructuralEq for SystemTime

source§

impl StructuralEq for getrandom::error::Error

source§

impl StructuralEq for DebugTypeSignature

source§

impl StructuralEq for DwoId

source§

impl StructuralEq for gimli::common::Encoding

source§

impl StructuralEq for LineEncoding

source§

impl StructuralEq for Register

source§

impl StructuralEq for DwAccess

source§

impl StructuralEq for DwAddr

source§

impl StructuralEq for DwAt

source§

impl StructuralEq for DwAte

source§

impl StructuralEq for DwCc

source§

impl StructuralEq for DwCfa

source§

impl StructuralEq for DwChildren

source§

impl StructuralEq for DwDefaulted

source§

impl StructuralEq for DwDs

source§

impl StructuralEq for DwDsc

source§

impl StructuralEq for DwEhPe

source§

impl StructuralEq for DwEnd

source§

impl StructuralEq for DwForm

source§

impl StructuralEq for DwId

source§

impl StructuralEq for DwIdx

source§

impl StructuralEq for DwInl

source§

impl StructuralEq for DwLang

source§

impl StructuralEq for DwLle

source§

impl StructuralEq for DwLnct

source§

impl StructuralEq for DwLne

source§

impl StructuralEq for DwLns

source§

impl StructuralEq for DwMacro

source§

impl StructuralEq for DwOp

source§

impl StructuralEq for DwOrd

source§

impl StructuralEq for DwRle

source§

impl StructuralEq for DwSect

source§

impl StructuralEq for DwSectV2

source§

impl StructuralEq for DwTag

source§

impl StructuralEq for DwUt

source§

impl StructuralEq for DwVirtuality

source§

impl StructuralEq for DwVis

source§

impl StructuralEq for gimli::endianity::BigEndian

source§

impl StructuralEq for gimli::endianity::LittleEndian

source§

impl StructuralEq for Abbreviation

source§

impl StructuralEq for AttributeSpecification

source§

impl StructuralEq for ArangeEntry

source§

impl StructuralEq for Augmentation

source§

impl StructuralEq for BaseAddresses

source§

impl StructuralEq for SectionBaseAddresses

source§

impl StructuralEq for UnitIndexSection

source§

impl StructuralEq for FileEntryFormat

source§

impl StructuralEq for LineRow

source§

impl StructuralEq for ReaderOffsetId

source§

impl StructuralEq for gimli::read::rnglists::Range

source§

impl StructuralEq for StoreOnHeap

source§

impl StructuralEq for object::endian::BigEndian

source§

impl StructuralEq for object::endian::LittleEndian

source§

impl StructuralEq for CompressedFileRange

source§

impl StructuralEq for object::read::Error

source§

impl StructuralEq for object::read::SectionIndex

source§

impl StructuralEq for object::read::SymbolIndex

source§

impl StructuralEq for object::write::elf::writer::SectionIndex

source§

impl StructuralEq for object::write::elf::writer::SymbolIndex

source§

impl StructuralEq for StringId

source§

impl StructuralEq for ComdatId

source§

impl StructuralEq for object::write::Error

source§

impl StructuralEq for object::write::SectionId

source§

impl StructuralEq for SymbolId

source§

impl StructuralEq for DefaultToHost

source§

impl StructuralEq for DefaultToUnknown

source§

impl StructuralEq for Triple

source§

impl StructuralEq for OpaqueOrigin

1.33.0 · source§

impl StructuralEq for PhantomPinned

§

impl StructuralEq for BidiClass

§

impl StructuralEq for IsNormalized

§

impl StructuralEq for Level

§

impl StructuralEq for TryReserveError

source§

impl<'a> StructuralEq for ComponentDefinedType<'a>

1.0.0 · source§

impl<'a> StructuralEq for Component<'a>

1.0.0 · source§

impl<'a> StructuralEq for Prefix<'a>

source§

impl<'a> StructuralEq for VariantCase<'a>

1.10.0 · source§

impl<'a> StructuralEq for Location<'a>

source§

impl<'a> StructuralEq for Utf8Chunk<'a>

1.0.0 · source§

impl<'a> StructuralEq for PrefixComponent<'a>

source§

impl<'a> StructuralEq for Metadata<'a>

source§

impl<'a> StructuralEq for MetadataBuilder<'a>

source§

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

source§

impl<'bases, Section, R> StructuralEq for PartialFrameDescriptionEntry<'bases, Section, R>where R: Reader, Section: UnwindSection<R>,

source§

impl<'data> StructuralEq for CodeView<'data>

source§

impl<'data> StructuralEq for CompressedData<'data>

source§

impl<'data> StructuralEq for Export<'data>

source§

impl<'data> StructuralEq for Import<'data>

source§

impl<'data> StructuralEq for ObjectMapEntry<'data>

source§

impl<'data> StructuralEq for SymbolMapName<'data>

source§

impl<'data> StructuralEq for Bytes<'data>

source§

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

1.55.0 · source§

impl<B, C> StructuralEq for ControlFlow<B, C>

source§

impl<E> StructuralEq for I16<E>where E: Endian,

source§

impl<E> StructuralEq for I32<E>where E: Endian,

source§

impl<E> StructuralEq for I64<E>where E: Endian,

source§

impl<E> StructuralEq for U16<E>where E: Endian,

source§

impl<E> StructuralEq for U32<E>where E: Endian,

source§

impl<E> StructuralEq for U64<E>where E: Endian,

source§

impl<E> StructuralEq for I16Bytes<E>where E: Endian,

source§

impl<E> StructuralEq for I32Bytes<E>where E: Endian,

source§

impl<E> StructuralEq for I64Bytes<E>where E: Endian,

source§

impl<E> StructuralEq for U16Bytes<E>where E: Endian,

source§

impl<E> StructuralEq for U32Bytes<E>where E: Endian,

source§

impl<E> StructuralEq for U64Bytes<E>where E: Endian,

1.0.0 · source§

impl<Idx> StructuralEq for wasmtime_environ::__core::ops::Range<Idx>

1.0.0 · source§

impl<Idx> StructuralEq for RangeFrom<Idx>

1.26.0 · source§

impl<Idx> StructuralEq for RangeInclusive<Idx>

1.0.0 · source§

impl<Idx> StructuralEq for RangeTo<Idx>

1.26.0 · source§

impl<Idx> StructuralEq for RangeToInclusive<Idx>

source§

impl<K, V> StructuralEq for PrimaryMap<K, V>where K: EntityRef,

source§

impl<Offset> StructuralEq for UnitType<Offset>where Offset: ReaderOffset,

source§

impl<R> StructuralEq for CallFrameInstruction<R>where R: Reader,

source§

impl<R> StructuralEq for CfaRule<R>where R: Reader,

source§

impl<R> StructuralEq for RegisterRule<R>where R: Reader,

source§

impl<R> StructuralEq for DebugFrame<R>where R: Reader,

source§

impl<R> StructuralEq for EhFrame<R>where R: Reader,

source§

impl<R> StructuralEq for EhFrameHdr<R>where R: Reader,

source§

impl<R> StructuralEq for LocationListEntry<R>where R: Reader,

source§

impl<R> StructuralEq for Expression<R>where R: Reader,

source§

impl<R> StructuralEq for Attribute<R>where R: Reader,

source§

impl<R, A> StructuralEq for UnwindContext<R, A>where R: Reader, A: UnwindContextStorage<R>,

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

impl<S> StructuralEq for Host<S>

source§

impl<Section> StructuralEq for SymbolFlags<Section>

1.17.0 · source§

impl<T> StructuralEq for Bound<T>

1.0.0 · source§

impl<T> StructuralEq for Option<T>

1.36.0 · source§

impl<T> StructuralEq for Poll<T>

1.0.0 · source§

impl<T> StructuralEq for TrySendError<T>

source§

impl<T> StructuralEq for UnitSectionOffset<T>

source§

impl<T> StructuralEq for DieReference<T>

source§

impl<T> StructuralEq for PackedOption<T>where T: ReservedValue,

1.19.0 · source§

impl<T> StructuralEq for Reverse<T>

1.20.0 · source§

impl<T> StructuralEq for ManuallyDrop<T>where T: ?Sized,

source§

impl<T> StructuralEq for Saturating<T>

1.0.0 · source§

impl<T> StructuralEq for Wrapping<T>

1.0.0 · source§

impl<T> StructuralEq for Cursor<T>

1.0.0 · source§

impl<T> StructuralEq for SendError<T>

source§

impl<T> StructuralEq for DebugAbbrevOffset<T>

source§

impl<T> StructuralEq for DebugAddrBase<T>

source§

impl<T> StructuralEq for DebugAddrIndex<T>

source§

impl<T> StructuralEq for DebugArangesOffset<T>

source§

impl<T> StructuralEq for DebugFrameOffset<T>

source§

impl<T> StructuralEq for DebugInfoOffset<T>

source§

impl<T> StructuralEq for DebugLineOffset<T>

source§

impl<T> StructuralEq for DebugLineStrOffset<T>

source§

impl<T> StructuralEq for DebugLocListsBase<T>

source§

impl<T> StructuralEq for DebugLocListsIndex<T>

source§

impl<T> StructuralEq for DebugMacinfoOffset<T>

source§

impl<T> StructuralEq for DebugMacroOffset<T>

source§

impl<T> StructuralEq for DebugRngListsBase<T>

source§

impl<T> StructuralEq for DebugRngListsIndex<T>

source§

impl<T> StructuralEq for DebugStrOffset<T>

source§

impl<T> StructuralEq for DebugStrOffsetsBase<T>

source§

impl<T> StructuralEq for DebugStrOffsetsIndex<T>

source§

impl<T> StructuralEq for DebugTypesOffset<T>

source§

impl<T> StructuralEq for EhFrameOffset<T>

source§

impl<T> StructuralEq for LocationListsOffset<T>

source§

impl<T> StructuralEq for RangeListsOffset<T>

source§

impl<T> StructuralEq for RawRangeListsOffset<T>

source§

impl<T> StructuralEq for UnitOffset<T>

source§

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

1.0.0 · source§

impl<T, E> StructuralEq for Result<T, E>

source§

impl<Y, R> StructuralEq for GeneratorState<Y, R>