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
- Details for primitively consuming an equality.
- type_
functions TypeFunction
s 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§
- TypeEq
- Evidence of the equality
T == U
as a zero-sized type.
Traits§
- IsEqual
- Equality at a constraint level, as a type alias. Reflexivity holds.
Functions§
- coerce
- Coerce a value of type
T
to a value of typeU
, given evidence thatT == U
. - coerce_
box alloc
- Coerce a value of type
Box<T>
to a value of typeBox<U>
, given evidence thatT == U
. - coerce_
mut - Coerce a value of type
&mut T
to a value of type&mut U
, given evidence thatT == U
. - coerce_
ref - Coerce a value of type
&T
to a value of type&U
, given evidence thatT == U
. - maybe_
type_ eq test-for-type-equality
- Optionally obtain a type equality if the type checker can solve
T == U
. - refl
- Construct evidence of the reflexive equality
T == T
. - substitute
- 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. - trivial_
eq - Construct evidence of
TypeEq<T, U>
under the constraintT: IsEqual<U>
.