Crate type_equalities[][src]

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 == U as a zero-sized type.

Traits

Equality at a constraint level, as a type alias. Reflexivity holds.

Functions

Coerce a value of type T to a value of type U, given evidence that T == U.

Coerce a value of type Box<T> to a value of type Box<U>, given evidence that T == U.

Coerce a value of type &mut T to a value of type &mut U, given evidence that T == U.

Coerce a value of type &T to a value of type &U, given evidence that T == U.

maybe_type_eqtest-for-type-equality

Optionally obtain a type equality if the type checker can solve T == 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 constraint T: IsEqual<U>.