Trait concordium_std::marker::StructuralEq [−][src]
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); 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.
Implementations on Foreign Types
impl StructuralEq for RecvTimeoutError
[src]
impl StructuralEq for IpAddr
[src]
impl<T> StructuralEq for TrySendError<T>
[src]
impl StructuralEq for Ipv6MulticastScope
[src]
impl StructuralEq for FromVecWithNulError
[src]
impl StructuralEq for AddrParseError
[src]
impl StructuralEq for BacktraceStatus
[src]
impl<T> StructuralEq for Cursor<T>
[src]
impl StructuralEq for Output
[src]
impl StructuralEq for FromBytesWithNulError
[src]
impl StructuralEq for IntoStringError
[src]
impl StructuralEq for TryRecvError
[src]
impl StructuralEq for Permissions
[src]
impl StructuralEq for AccessError
[src]
impl StructuralEq for SocketAddr
[src]
impl<T> StructuralEq for SendError<T>
[src]
impl StructuralEq for Shutdown
[src]
impl<'a> StructuralEq for PrefixComponent<'a>
[src]
impl StructuralEq for SystemTime
[src]
impl StructuralEq for CString
[src]
impl StructuralEq for RecvError
[src]
impl StructuralEq for NulError
[src]
impl<'a> StructuralEq for Prefix<'a>
[src]
impl<'a> StructuralEq for Component<'a>
[src]
impl StructuralEq for WaitTimeoutResult
[src]
impl StructuralEq for VarError
[src]
impl StructuralEq for FileType
[src]
impl StructuralEq for StripPrefixError
[src]
impl StructuralEq for ExitStatus
[src]
impl StructuralEq for SeekFrom
[src]
impl StructuralEq for ThreadId
[src]
impl StructuralEq for ErrorKind
[src]
impl StructuralEq for Instant
[src]
impl<'a> StructuralEq for Location<'a>
[src]
impl StructuralEq for DecodeUtf16Error
[src]
impl<Idx> StructuralEq for RangeToInclusive<Idx>
[src]
impl<Idx> StructuralEq for RangeFrom<Idx>
[src]
impl StructuralEq for Utf8Error
[src]
impl StructuralEq for TypeId
[src]
impl<T> StructuralEq for Reverse<T>
[src]
impl<T> StructuralEq for Poll<T>
[src]
impl StructuralEq for NoneError
[src]
impl StructuralEq for RangeFull
[src]
impl<'a> StructuralEq for Utf8LossyChunk<'a>
[src]
impl<T, E> StructuralEq for Result<T, E>
[src]
impl<Idx> StructuralEq for RangeInclusive<Idx>
[src]
impl<Idx> StructuralEq for Range<Idx>
[src]
impl StructuralEq for Ordering
[src]
impl<T> StructuralEq for Option<T>
[src]
impl StructuralEq for CharTryFromError
[src]
impl StructuralEq for ParseBoolError
[src]
impl StructuralEq for ParseCharError
[src]
impl StructuralEq for Error
[src]
impl StructuralEq for CpuidResult
[src]
impl<Idx> StructuralEq for RangeTo<Idx>
[src]
impl<Y, R> StructuralEq for GeneratorState<Y, R>
[src]
impl StructuralEq for LayoutError
[src]
impl StructuralEq for Layout
[src]
impl StructuralEq for SearchStep
[src]
impl StructuralEq for Duration
[src]
impl StructuralEq for AllocError
[src]
impl StructuralEq for FromUtf8Error
[src]
impl StructuralEq for Pages
impl StructuralEq for Pages
impl StructuralEq for Words
impl StructuralEq for Bytes
impl StructuralEq for Words
Loading content...Implementors
impl StructuralEq for TryReserveError
[src]
impl StructuralEq for Address
[src]
impl StructuralEq for AmountParseError
[src]
impl StructuralEq for LogError
[src]
impl StructuralEq for NewContractNameError
[src]
impl StructuralEq for NewReceiveNameError
[src]
impl StructuralEq for ParseDurationError
[src]
impl StructuralEq for FpCategory
1.0.0[src]
impl StructuralEq for IntErrorKind
[src]
impl StructuralEq for Fields
[src]
impl StructuralEq for SizeLength
[src]
impl StructuralEq for Type
[src]
impl StructuralEq for ActionsTree
[src]
impl StructuralEq for ContractStateError
[src]
impl StructuralEq for NonZeroI8
1.34.0[src]
impl StructuralEq for NonZeroI16
1.34.0[src]
impl StructuralEq for NonZeroI32
1.34.0[src]
impl StructuralEq for NonZeroI64
1.34.0[src]
impl StructuralEq for NonZeroI128
1.34.0[src]
impl StructuralEq for NonZeroIsize
1.34.0[src]
impl StructuralEq for NonZeroU8
1.28.0[src]
impl StructuralEq for NonZeroU16
1.28.0[src]
impl StructuralEq for NonZeroU32
1.28.0[src]
impl StructuralEq for NonZeroU64
1.28.0[src]
impl StructuralEq for NonZeroU128
1.28.0[src]
impl StructuralEq for NonZeroUsize
1.28.0[src]
impl StructuralEq for ParseFloatError
1.0.0[src]
impl StructuralEq for ParseIntError
1.0.0[src]
impl StructuralEq for TryFromIntError
1.34.0[src]
impl StructuralEq for AccountAddress
[src]
impl StructuralEq for Amount
[src]
impl StructuralEq for AttributeTag
[src]
impl StructuralEq for ContractAddress
[src]
impl StructuralEq for concordium_std::Duration
[src]
impl StructuralEq for OwnedContractName
[src]
impl StructuralEq for OwnedReceiveName
[src]
impl StructuralEq for ParseError
[src]
impl StructuralEq for Reject
[src]
impl StructuralEq for String
1.0.0[src]
impl StructuralEq for Timestamp
[src]
impl StructuralEq for PhantomPinned
1.33.0[src]
impl<'a> StructuralEq for ContractName<'a>
[src]
impl<'a> StructuralEq for ReceiveName<'a>
[src]
impl<T> StructuralEq for Bound<T>
1.17.0[src]
impl<T> StructuralEq for BTreeSet<T>
1.0.0[src]
impl<T> StructuralEq for ManuallyDrop<T> where
T: ?Sized,
1.20.0[src]
T: ?Sized,
impl<T> StructuralEq for Wrapping<T>
1.0.0[src]
impl<T> StructuralEq for PhantomData<T> where
T: ?Sized,
[src]
T: ?Sized,