Trait rust_examples::dependent::AddEq [−][src]
pub trait AddEq<N, X> { }Expand description
Relation M: AddEq<N, X> is interpreted as M + N = X.
An obvious alternative is to define trait EqAdd<M, N> {} with the interpretaton:
Relation
X: EqAdd<M, N>is interpreted asX = M + N.
The problem with such an approach is in the specification of Zero being the neutral element:
impl<N: Nat> EqAdd<Zero, N> for N {}Since N here is generic, it would need Specialization for it not to overlap with the
specification of associativity:
impl<M: Nat, N: Nat, X: Nat + EqAdd<M, N>> EqAdd<M, Succ<N>> for Succ<X> {}