2 releases

0.1.1 Aug 28, 2020
0.1.0 Aug 28, 2020

#8 in #consts

Custom license

21KB
675 lines

Workflow Status

boundnum

This crate provides a type boundary and a numeric type bounded by it.

Example

use boundnum::{expr::*, typenum::consts::*, Bounded, Boundable};

fn main() {
    let less4 = Bounded::<u8, Le<Arg, U4>>::new::<U1>();

    let mul_of_two: Bounded<u8, Eq<U0, Rem<Arg, U2>>> =
        (*less4 + 3).bound().unwrap_or(Bounded::new::<U0>());
}

lib.rs:

This crate provides a type boundary and a numeric type bounded by it.

Example

use boundnum::{expr::*, typenum::consts::*, Bounded, Boundable};

fn main() {
    let less4 = Bounded::<u8, Le<Arg, U4>>::new::<U1>();

    let mul_of_two: Bounded<u8, Eq<U0, Rem<Arg, U2>>> =
        (*less4 + 3).bound().unwrap_or(Bounded::new::<U0>());
}

Dependencies

~2MB
~50K SLoC