Trait RestrictedMath

pub trait RestrictedMath {
    type Arg: 'static + Copy;
    type Value: 'static + Copy;

    // Required methods
    fn checked_add(
        &self,
        arg: Self::Arg,
    ) -> Result<Restrict<Self::Value>, Self::Arg>;
    fn checked_sub(
        &self,
        arg: Self::Arg,
    ) -> Result<Restrict<Self::Value>, Self::Arg>;
    fn checked_mul(
        &self,
        arg: Self::Arg,
    ) -> Result<Restrict<Self::Value>, Self::Arg>;
}
Expand description

Common checked math operations for the Restrict type

Required Associated Types§

type Arg: 'static + Copy

Argument for the math operations

type Value: 'static + Copy

Return value, generally the same as Arg

Required Methods§

fn checked_add( &self, arg: Self::Arg, ) -> Result<Restrict<Self::Value>, Self::Arg>

Checked addition, see usize::checked_add

fn checked_sub( &self, arg: Self::Arg, ) -> Result<Restrict<Self::Value>, Self::Arg>

Checked subtraction, see usize::checked_sub

fn checked_mul( &self, arg: Self::Arg, ) -> Result<Restrict<Self::Value>, Self::Arg>

Checked multiplication, see usize::checked_mul

Implementors§

§

impl RestrictedMath for Restrict<u8>

§

type Arg = u8

§

type Value = u8

§

impl RestrictedMath for Restrict<u16>

§

type Arg = u16

§

type Value = u16

§

impl RestrictedMath for Restrict<usize>

§

type Arg = usize

§

type Value = usize

§

impl<R, A> RestrictedMath for Result<R, A>
where R: RestrictedMath, A: 'static + Copy,

§

type Arg = <R as RestrictedMath>::Arg

§

type Value = <R as RestrictedMath>::Value