pub struct TypeEq<T: ?Sized, U: ?Sized> { /* private fields */ }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§
Source§impl<T: ?Sized, U: ?Sized> TypeEq<T, U>
impl<T: ?Sized, U: ?Sized> TypeEq<T, U>
Sourcepub const fn trivial() -> Selfwhere
T: IsEqual<U>,
pub const fn trivial() -> Selfwhere
T: IsEqual<U>,
Same as crate::trivial_eq.
Note: this function is const only on nightly, since it depends on the
const_fn_trait_bound feature.
Sourcepub fn substitute<F: TypeFunction<T> + TypeFunction<U>>(
self,
t: ApF<F, T>,
) -> ApF<F, U>
pub fn substitute<F: TypeFunction<T> + TypeFunction<U>>( self, t: ApF<F, T>, ) -> ApF<F, U>
Same as crate::substitute.
Sourcepub fn coerce(self, t: T) -> U
pub fn coerce(self, t: T) -> U
Same as crate::coerce. Note that this is operationally a no-op.
§Examples
assert_eq!(refl().coerce(42), 42);Sourcepub 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
Trait Implementations§
impl<T: ?Sized, U: ?Sized> Copy for TypeEq<T, U>
Auto Trait Implementations§
impl<T, U> Freeze for TypeEq<T, U>
impl<T, U> !RefUnwindSafe for TypeEq<T, U>
impl<T, U> !Send for TypeEq<T, U>
impl<T, U> !Sync for TypeEq<T, U>
impl<T, U> Unpin for TypeEq<T, U>
impl<T, U> !UnwindSafe for TypeEq<T, U>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more