Trait TypedAdd

Source
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);

Required Associated Types§

Implementors§

Source§

impl<N: IsInteger, H0: Hex, H1: Hex, H2: Hex, H3: Hex, H4: Hex, H5: Hex, H6: Hex, H7: Hex, R: IsInteger> TypedAdd<N> for TypedInteger<H0, H1, H2, H3, H4, H5, H6, H7>
where TypedInteger<H0, H1, H2, H3, H4, H5, H6, H7>: _Add<N, Output = R>,