Struct type_equalities::TypeEq [−][src]
Expand description
Evidence of the equality T == U
as a zero-sized type.
assert_eq!(core::mem::size_of::<TypeEq<T, U>>(), 0);
It is important to note that the TypeEq
is invariant
in both arguments.
ⓘ
fn coerce_lt<'a, 'b: 'a, T>(eq: TypeEq<&'b T, &'b T>)
-> TypeEq<&'b T, &'a T>
{
eq
}
ⓘ
fn coerce_lt_inv<'a, 'b: 'a, T>(eq: TypeEq<&'a T, &'a T>)
-> TypeEq<&'a T, &'b T>
{
eq
}
Unsizing also does not work for TypeEq.
ⓘ
fn coerce_dyn<T: core::fmt::Debug>(eq: &TypeEq<T, T>)
-> &TypeEq<T, dyn core::fmt::Debug>
{
eq
}
Implementations
Same as crate::trivial_eq
.
Note: this function is const
only on nightly, since it depends on the
const_fn_trait_bound
feature.
pub fn substitute<F: TypeFunction<T> + TypeFunction<U>>(
self,
t: ApF<F, T>
) -> ApF<F, U> where
ApF<F, T>: Sized,
ApF<F, U>: Sized,
pub fn substitute<F: TypeFunction<T> + TypeFunction<U>>(
self,
t: ApF<F, T>
) -> ApF<F, U> where
ApF<F, T>: Sized,
ApF<F, U>: Sized,
Same as crate::substitute
.
Same as crate::coerce
. Note that this is operationally a no-op.
Examples
assert_eq!(refl().coerce(42), 42);
pub fn lift_through<F: TypeFunction<T> + TypeFunction<U>>(
self
) -> TypeEq<ApF<F, T>, ApF<F, U>>
pub fn lift_through<F: TypeFunction<T> + TypeFunction<U>>(
self
) -> TypeEq<ApF<F, T>, ApF<F, U>>
Lift the type equality through any TypeFunction
Use the observed equality to call the consumer to compute a result.
Consider using either TypeEq::coerce
or TypeEq::lift_through
first.
Trait Implementations
Auto Trait Implementations
impl<T, U> !RefUnwindSafe for TypeEq<T, U>
impl<T, U> !UnwindSafe for TypeEq<T, U>
Blanket Implementations
type Alias = T
type Alias = T
Always set to Self
, but the type checker doesn’t reduce T::Alias
to T
.
Mutably borrows from an owned value. Read more