Trait typenum::type_operators::Same [−][src]
pub trait Same<Rhs = Self> { type Output; }
A type operator that ensures that Rhs
is the same as Self
, it is mainly useful
for writing macros that can take arbitrary binary or unary operators.
Same
is implemented generically for all types; it should never need to be implemented
for anything else.
Note that Rust lazily evaluates types, so this will only fail for two different types if
the Output
is used.
Example
use typenum::{Same, U4, U5, Unsigned}; assert_eq!(<U5 as Same<U5>>::Output::to_u32(), 5); // Only an error if we use it: type Undefined = <U5 as Same<U4>>::Output; // Compiler error: // Undefined::to_u32();