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, H0, R0: Hex, C0: Hex, H1, R1: Hex, C1: Hex, H2, R2: Hex, C2: Hex, H3, R3: Hex, C3: Hex, H4, R4: Hex, C4: Hex, H5, R5: Hex, C5: Hex, H6, R6: Hex, C6: Hex, H7, R7: Hex, C7> TypedAdd<N> for TypedInteger<H0, H1, H2, H3, H4, H5, H6, H7>where N: IsInteger, H0: HexAdd<N::Hex0, Output = R0, Carry = C0> + Hex, H1: HexAdd3<N::Hex1, C0, Output = R1, Carry = C1> + Hex, H2: HexAdd3<N::Hex2, C1, Output = R2, Carry = C2> + Hex, H3: HexAdd3<N::Hex3, C2, Output = R3, Carry = C3> + Hex, H4: HexAdd3<N::Hex4, C3, Output = R4, Carry = C4> + Hex, H5: HexAdd3<N::Hex5, C4, Output = R5, Carry = C5> + Hex, H6: HexAdd3<N::Hex6, C5, Output = R6, Carry = C6> + Hex, H7: HexAdd3<N::Hex7, C6, Output = R7, Carry = C7> + Hex, C7: HexAssertEqual<_0> + Hex,

§

type Output = TypedInteger<R0, R1, R2, R3, R4, R5, R6, R7>