Trait tinychain::scalar::NumberInstance[]

pub trait NumberInstance: Copy + Default + From<Boolean> + Into<Number> + Add<Self, Output = Self> + AddAssign<Self> + Sub<Self, Output = Self> + SubAssign<Self> + Mul<Self, Output = Self> + MulAssign<Self> + Div<Self, Output = Self> + DivAssign<Self> + Product<Self> + Sum<Self> + Debug + Display {
    type Abs: NumberInstance;
    type Exp: NumberInstance;
    type Class: NumberClass;
    pub fn class(&self) -> Self::Class;
pub fn into_type(
        self,
        dtype: Self::Class
    ) -> <Self::Class as NumberClass>::Instance;
pub fn abs(self) -> Self::Abs;
pub fn pow(self, exp: Self::Exp) -> Self; pub fn and(self, other: Self) -> Self
    where
        Boolean: CastFrom<Self>
, { ... }
pub fn not(self) -> Self
    where
        Boolean: CastFrom<Self>
, { ... }
pub fn or(self, other: Self) -> Self
    where
        Boolean: CastFrom<Self>
, { ... }
pub fn xor(self, other: Self) -> Self
    where
        Boolean: CastFrom<Self>
, { ... } }

Defines common operations on numeric types supported by Number.

Associated Types

Loading content...

Required methods

pub fn class(&self) -> Self::Class

Get an impl of NumberClass describing this number.

pub fn into_type(
    self,
    dtype: Self::Class
) -> <Self::Class as NumberClass>::Instance

Cast this number into the specified NumberClass.

pub fn abs(self) -> Self::Abs

Calculate the absolute value of this number.

pub fn pow(self, exp: Self::Exp) -> Self

Raise this number to the given exponent.

Loading content...

Provided methods

pub fn and(self, other: Self) -> Self where
    Boolean: CastFrom<Self>, 

Return true if self and other are nonzero.

pub fn not(self) -> Self where
    Boolean: CastFrom<Self>, 

Return true if this number is zero.

pub fn or(self, other: Self) -> Self where
    Boolean: CastFrom<Self>, 

Return true if self or other is nonzero.

pub fn xor(self, other: Self) -> Self where
    Boolean: CastFrom<Self>, 

Return true if exactly one of self and other is zero.

Loading content...

Implementors

impl NumberInstance for Complex

type Abs = Float

type Exp = Complex

type Class = ComplexType

impl NumberInstance for Float

type Abs = Float

type Exp = Float

type Class = FloatType

impl NumberInstance for Int

type Abs = Int

type Exp = UInt

type Class = IntType

impl NumberInstance for Number

type Abs = Number

type Exp = Number

type Class = NumberType

impl NumberInstance for UInt

type Abs = UInt

type Exp = UInt

type Class = UIntType

impl NumberInstance for Boolean

type Abs = Boolean

type Exp = Boolean

type Class = BooleanType

Loading content...