Trait syllogism::IsNot [−][src]
pub trait IsNot<T> { }
Expand description
A trait to inform the compiler that two data types are distinct.
This allows you to use specialization up to some extend. See the crate level documentation for more info.
A data type should never implement IsNot<Self>
.
Implementing IsNot
correctly for each pair of data types at hand can be
error prone. E.g. if there are three data types at play, T1
, T2
, T3
.
If you want to allow specialization for any of these data types, giving the other two the
“default” treatment, then you need six implementations of the IsNot
trait:
use syllogism::IsNot;
impl IsNot<T2> for T1 {}
impl IsNot<T3> for T1 {}
impl IsNot<T1> for T2 {}
impl IsNot<T3> for T2 {}
impl IsNot<T1> for T3 {}
impl IsNot<T2> for T3 {}
The syllogism-macro
crate provides procedural macros to generate these impl
s for you,
and also offers some techniques that allow extending the set of data types across crate
boundaries. We refer to the documentation of the syllogism-macro
crate for more information.