pub fn type_eq<T1, T2>() -> boolExpand description
Returns true if the T1 and T2 types are equal.
This method requires only T2 to implement LifetimeFree trait.
Library tests ensure that type comparisons are performed at compile time and
are fully optimized with no runtime cost at opt-level >= 1. Note that the
release profile uses opt-level = 3 by default.
ยงExamples
use try_specialize::type_eq;
assert!(type_eq::<(), ()>());
assert!(!type_eq::<(), u8>());
assert!(type_eq::<u8, u8>());
assert!(!type_eq::<u8, u32>());
assert!(type_eq::<[u8], [u8]>());
assert!(type_eq::<[u8; 8], [u8; 8]>());
assert!(!type_eq::<[u8; 8], [u8]>());
assert!(!type_eq::<[u8], [u8; 8]>());
assert!(!type_eq::<[u8; 8], [u8; 16]>());
assert!(type_eq::<str, str>());
assert!(type_eq::<[u8], [u8]>());
assert!(!type_eq::<str, [u8]>());
assert!(!type_eq::<[u8], [u8; 4]>());
assert!(type_eq::<String, String>());