Function type_equalities::maybe_type_eq[][src]

pub const fn maybe_type_eq<T: ?Sized, U: ?Sized>() -> Option<TypeEq<T, U>>
This is supported on crate feature test-for-type-equality only.
Expand description

Optionally obtain a type equality if the type checker can solve T == U.

Note that this depends on #![feature(specialization)] and works by overloading some defined instances. Do not depend on always getting back a Some(..), but it will work fine in the simple cases.

Examples

assert_eq!(maybe_type_eq::<u32, u32>()?.coerce(42), 42);