Numeric

Trait Numeric 

Source
pub trait Numeric:
    Neg<Output = Self>
    + Add<Output = Self>
    + Sub<Output = Self>
    + Mul<Output = Self>
    + Div<Output = Self>
    + AddAssign
    + SubAssign
    + From<i32>
    + Copy
    + Clone
    + Default
    + Sized
    + 'static { }
Expand description

定义 Numeric trait,约束 T 必须实现基本数值运算 包括:

  • 一元负号运算 (Neg)
  • 加减乘除运算 (Add, Sub, Mul, Div)
  • 复合赋值运算 (AddAssign, SubAssign)
  • 从i32转换 (From)
  • 复制语义 (Copy, Clone)
  • 默认值 (Default)
  • 静态生命周期 (’static)

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 f64

Source§

impl Numeric for i64

Implementors§