Trait cairo_vm::with_std::marker::StructuralEq
source · pub trait StructuralEq { }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);
#[allow(pointer_structural_match)]
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§
impl StructuralEq for Dictionary
impl StructuralEq for BuiltinName
impl StructuralEq for OffsetValue
impl StructuralEq for ApUpdate
impl StructuralEq for FpUpdate
impl StructuralEq for Op1Addr
impl StructuralEq for Opcode
impl StructuralEq for PcUpdate
impl StructuralEq for Register
impl StructuralEq for Res
impl StructuralEq for MaybeRelocatable
impl StructuralEq for ExecScopeError
impl StructuralEq for InsufficientAllocatedCellsError
impl StructuralEq for BuiltinAdditionalData
impl StructuralEq for CairoArg
impl StructuralEq for cairo_vm::with_std::cmp::Ordering
impl StructuralEq for cairo_vm::with_std::fmt::Alignment
impl StructuralEq for FpCategory
impl StructuralEq for IntErrorKind
impl StructuralEq for SearchStep
impl StructuralEq for cairo_vm::with_std::sync::atomic::Ordering
impl StructuralEq for RecvTimeoutError
impl StructuralEq for TryRecvError
impl StructuralEq for TryReserveErrorKind
impl StructuralEq for AsciiChar
impl StructuralEq for IpAddr
impl StructuralEq for Ipv6MulticastScope
impl StructuralEq for SocketAddr
impl StructuralEq for BacktraceStatus
impl StructuralEq for VarError
impl StructuralEq for SeekFrom
impl StructuralEq for std::io::error::ErrorKind
impl StructuralEq for Shutdown
impl StructuralEq for BacktraceStyle
impl StructuralEq for AllowedEnumVariants
impl StructuralEq for IntegerType
impl StructuralEq for hashbrown::TryReserveError
impl StructuralEq for nom::error::ErrorKind
impl StructuralEq for Needed
impl StructuralEq for Endianness
impl StructuralEq for Sign
impl StructuralEq for BernoulliError
impl StructuralEq for WeightedError
impl StructuralEq for Category
impl StructuralEq for Value
impl StructuralEq for bool
impl StructuralEq for char
impl StructuralEq for i8
impl StructuralEq for i16
impl StructuralEq for i32
impl StructuralEq for i64
impl StructuralEq for i128
impl StructuralEq for isize
impl StructuralEq for str
impl StructuralEq for u8
impl StructuralEq for u16
impl StructuralEq for u32
impl StructuralEq for u64
impl StructuralEq for u128
impl StructuralEq for ()
impl StructuralEq for usize
impl StructuralEq for DictManager
impl StructuralEq for DictTracker
impl StructuralEq for HintReference
impl StructuralEq for ApTracking
impl StructuralEq for Attribute
impl StructuralEq for DebugInfo
impl StructuralEq for FlowTrackingData
impl StructuralEq for HintLocation
impl StructuralEq for HintParams
impl StructuralEq for Identifier
impl StructuralEq for InputFile
impl StructuralEq for InstructionLocation
impl StructuralEq for cairo_vm::serde::deserialize_program::Location
impl StructuralEq for Member
impl StructuralEq for Reference
impl StructuralEq for ReferenceManager
impl StructuralEq for ValueAddress
impl StructuralEq for String
impl StructuralEq for Instruction
impl StructuralEq for Program
impl StructuralEq for Relocatable
impl StructuralEq for CairoPie
impl StructuralEq for CairoPieMetadata
impl StructuralEq for CairoPieVersion
impl StructuralEq for OutputBuiltinAdditionalData
impl StructuralEq for PublicMemoryPage
impl StructuralEq for cairo_vm::vm::runners::cairo_pie::SegmentInfo
impl StructuralEq for StrippedProgram
impl StructuralEq for ExecutionResources
impl StructuralEq for cairo_vm::vm::runners::cairo_runner::SegmentInfo
impl StructuralEq for TraceEntry
impl StructuralEq for Operands
impl StructuralEq for OperandsAddresses
impl StructuralEq for AllocError
impl StructuralEq for Layout
impl StructuralEq for LayoutError
impl StructuralEq for TypeId
impl StructuralEq for cairo_vm::with_std::fmt::Error
impl StructuralEq for Assume
impl StructuralEq for NonZeroI8
impl StructuralEq for NonZeroI16
impl StructuralEq for NonZeroI32
impl StructuralEq for NonZeroI64
impl StructuralEq for NonZeroI128
impl StructuralEq for NonZeroIsize
impl StructuralEq for NonZeroU8
impl StructuralEq for NonZeroU16
impl StructuralEq for NonZeroU32
impl StructuralEq for NonZeroU64
impl StructuralEq for NonZeroU128
impl StructuralEq for NonZeroUsize
impl StructuralEq for ParseFloatError
impl StructuralEq for ParseIntError
impl StructuralEq for TryFromIntError
impl StructuralEq for RangeFull
impl StructuralEq for cairo_vm::with_std::ptr::Alignment
impl StructuralEq for ParseBoolError
impl StructuralEq for Utf8Error
impl StructuralEq for FromUtf8Error
impl StructuralEq for RecvError
impl StructuralEq for WaitTimeoutResult
impl StructuralEq for Duration
impl StructuralEq for TryFromFloatSecsError
impl StructuralEq for alloc::collections::TryReserveError
impl StructuralEq for CString
impl StructuralEq for FromVecWithNulError
impl StructuralEq for IntoStringError
impl StructuralEq for NulError
impl StructuralEq for CharTryFromError
impl StructuralEq for ParseCharError
impl StructuralEq for DecodeUtf16Error
impl StructuralEq for TryFromCharError
impl StructuralEq for CpuidResult
impl StructuralEq for FromBytesUntilNulError
impl StructuralEq for FromBytesWithNulError
impl StructuralEq for Ipv4Addr
impl StructuralEq for Ipv6Addr
impl StructuralEq for AddrParseError
impl StructuralEq for SocketAddrV4
impl StructuralEq for SocketAddrV6
impl StructuralEq for FileType
impl StructuralEq for Permissions
impl StructuralEq for UCred
impl StructuralEq for StripPrefixError
impl StructuralEq for ExitStatus
impl StructuralEq for ExitStatusError
impl StructuralEq for Output
impl StructuralEq for AccessError
impl StructuralEq for ThreadId
impl StructuralEq for Instant
impl StructuralEq for SystemTime
impl StructuralEq for Lsb0
impl StructuralEq for Msb0
impl StructuralEq for Felt252
impl StructuralEq for ParseFeltError
impl StructuralEq for getrandom::error::Error
impl StructuralEq for ParseBigIntError
impl StructuralEq for StepRng
impl StructuralEq for SmallRng
impl StructuralEq for StdRng
impl StructuralEq for Number
impl StructuralEq for AffinePoint
impl StructuralEq for ProjectivePoint
impl StructuralEq for ATerm
impl StructuralEq for B0
impl StructuralEq for B1
impl StructuralEq for Z0
impl StructuralEq for Equal
impl StructuralEq for Greater
impl StructuralEq for Less
impl StructuralEq for UTerm
impl StructuralEq for ChaCha8Core
impl StructuralEq for ChaCha12Core
impl StructuralEq for ChaCha20Core
impl StructuralEq for PhantomPinned
impl StructuralEq for Compress
impl StructuralEq for Const
impl StructuralEq for EmptyFlags
impl StructuralEq for Error
impl StructuralEq for ErrorKind
impl StructuralEq for FieldElement
impl StructuralEq for InvalidBufferSize
impl StructuralEq for InvalidLength
impl StructuralEq for LegendreSymbol
impl StructuralEq for MacError
impl StructuralEq for Mut
impl StructuralEq for NullPtrError
impl StructuralEq for Reciprocal
impl StructuralEq for Validate
impl StructuralEq for udouble
impl StructuralEq for vec256_storage
impl StructuralEq for vec512_storage
impl<'a> StructuralEq for Component<'a>
impl<'a> StructuralEq for Prefix<'a>
impl<'a> StructuralEq for Utf8Chunk<'a>
impl<'a> StructuralEq for core::panic::location::Location<'a>
impl<'a> StructuralEq for PrefixComponent<'a>
impl<'a, T, O> StructuralEq for IterOnes<'a, T, O>
impl<'a, T, O> StructuralEq for IterZeros<'a, T, O>
impl<A> StructuralEq for ExtendedGcd<A>
impl<B, C> StructuralEq for ControlFlow<B, C>
impl<Idx> StructuralEq for Range<Idx>
impl<Idx> StructuralEq for RangeFrom<Idx>
impl<Idx> StructuralEq for RangeInclusive<Idx>
impl<Idx> StructuralEq for RangeTo<Idx>
impl<Idx> StructuralEq for RangeToInclusive<Idx>
impl<Inner> StructuralEq for Frozen<Inner>where
Inner: Mutability,
impl<L, R> StructuralEq for Either<L, R>
impl<MOD, const LIMBS: usize> StructuralEq for Residue<MOD, LIMBS>where
MOD: ResidueParams<LIMBS>,
impl<R> StructuralEq for BitEnd<R>where
R: BitRegister,
impl<R> StructuralEq for BitIdx<R>where
R: BitRegister,
impl<R> StructuralEq for BitIdxError<R>where
R: BitRegister,
impl<R> StructuralEq for BitMask<R>where
R: BitRegister,
impl<R> StructuralEq for BitPos<R>where
R: BitRegister,
impl<R> StructuralEq for BitSel<R>where
R: BitRegister,
impl<T> StructuralEq for Bound<T>
impl<T> StructuralEq for TrySendError<T>
impl<T> StructuralEq for Option<T>
impl<T> StructuralEq for Poll<T>
impl<T> StructuralEq for BitPtrError<T>where
T: BitStore,
impl<T> StructuralEq for BitSpanError<T>where
T: BitStore,
impl<T> StructuralEq for &Twhere
T: ?Sized,
impl<T> StructuralEq for [T]
impl<T> StructuralEq for (T₁, T₂, …, Tₙ)
This trait is implemented for tuples up to twelve items long.