Skip to main content

Add

Trait Add 

Source
pub trait Add<Rhs> {
    type Result: Nat;
}
Expand description

Type-level addition. Add<A, B> computes A + B.

§Examples

use reflect_nat::{Z, S, Add};
use reify_reflect_core::{Reflect, RuntimeValue};

// 2 + 3 = 5
type Two = S<S<Z>>;
type Three = S<S<S<Z>>>;
type Five = <Two as Add<Three>>::Result;
assert_eq!(Five::reflect(), RuntimeValue::Nat(5));

Required Associated Types§

Source

type Result: Nat

The resulting type-level natural.

Implementors§

Source§

impl<M, N> Add<N> for S<M>
where M: Nat + Add<N>, N: Nat, <M as Add<N>>::Result: Nat,

Source§

type Result = S<<M as Add<N>>::Result>

Source§

impl<N> Add<N> for Z
where N: Nat,