Expand description
Implements TypeEq that can be passed around and used at runtime to safely coerce values,
references and other structures dependending on these types.
The equality type is zero-sized, and the coercion should optimize to a no-op in all cases.
This crate is ![no_std]. You can optionally turn off the alloc feature.
Modules§
- Details for primitively consuming an equality.
TypeFunctions have the amazing property that they can be used to push the equality of a type-level argument through to an equality of the type-level result.
Structs§
- Evidence of the equality
T == Uas a zero-sized type.
Traits§
- Equality at a constraint level, as a type alias. Reflexivity holds.
Functions§
- Coerce a value of type
Tto a value of typeU, given evidence thatT == U. - coerce_
box allocCoerce a value of typeBox<T>to a value of typeBox<U>, given evidence thatT == U. - Coerce a value of type
&mut Tto a value of type&mut U, given evidence thatT == U. - Coerce a value of type
&Tto a value of type&U, given evidence thatT == U. - maybe_
type_ eq test-for-type-equalityOptionally obtain a type equality if the type checker can solveT == U. - Construct evidence of the reflexive equality
T == T. - Our workhorse for most of the other coerce implementations, lifting the equality through an arbitrary
TypeFunction. Do consider using this before writing a custom Consumer. - Construct evidence of
TypeEq<T, U>under the constraintT: IsEqual<U>.