Skip to main content

Numeric

Trait Numeric 

Source
pub trait Numeric:
    Num
    + NumCast
    + Copy
    + PartialOrd
    + Zero
    + One
    + Neg<Output = Self>
    + Debug
    + Send
    + Sync
    + 'static {
    // Required methods
    fn supports_bitwise() -> bool;
    fn is_float() -> bool;
    fn numeric_pow(self, exp: Self) -> Option<Self>;
}
Expand description

Trait for types that can be used as numeric values in expressions.

This is a marker trait that combines the necessary bounds for basic arithmetic operations. Both float and integer types implement this.

Required Methods§

Source

fn supports_bitwise() -> bool

Whether this type supports bitwise operations.

Source

fn is_float() -> bool

Whether this type is a floating-point type.

Source

fn numeric_pow(self, exp: Self) -> Option<Self>

Compute self raised to the power of exp. For floats, uses powf. For integers, uses repeated multiplication (returns None for negative exponents).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Numeric for f32

Source§

impl Numeric for f64

Source§

impl Numeric for i32

Source§

impl Numeric for i64

Implementors§