pub trait TypedAdd<N: IsInteger> {
type Output: IsInteger;
}
Expand description
Denotes integer addition. If this says C7 does not implement HexAssertEq, this means it overflowed.
Example
use const_arithmetic::*;
let a = parse_integer!(3);
let b = parse_integer!(5);
let c = parse_integer!(8);
// This verifies that 3 + 5 = 8
fn example<P, Q, R>(_p: P, _q: Q, _r: R) where
P: IsInteger,
Q: IsInteger,
R: IsInteger,
P: TypedAdd<Q, Output = R>
{}
example(a, b, c);
// This is another way of implementing the above
fn example2<P, Q, R, S, T>(_p: P, _q: Q, _r: R) where
P: IsInteger,
Q: IsInteger,
R: IsInteger,
S: IsInteger,
T: Binary,
P: TypedAdd<Q, Output = S>,
R: TypedEqual<S, Output = T>,
T: AssertTrue {}
example2(a, b, c);