Trait ArithmeticOps

Source
pub trait ArithmeticOps<T>: Copy {
    // Required methods
    fn add(self, other: T) -> T;
    fn sub(self, other: T) -> T;
    fn mul(self, other: T) -> T;
    fn div(self, other: T) -> Result<T, TrapCode>;
}
Expand description

Arithmetic operations.

Required Methods§

Source

fn add(self, other: T) -> T

Add two values.

Source

fn sub(self, other: T) -> T

Subtract two values.

Source

fn mul(self, other: T) -> T

Multiply two values.

Source

fn div(self, other: T) -> Result<T, TrapCode>

Divide two values.

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 ArithmeticOps<f32> for f32

Source§

fn add(self, other: f32) -> f32

Source§

fn sub(self, other: f32) -> f32

Source§

fn mul(self, other: f32) -> f32

Source§

fn div(self, other: f32) -> Result<f32, TrapCode>

Source§

impl ArithmeticOps<f64> for f64

Source§

fn add(self, other: f64) -> f64

Source§

fn sub(self, other: f64) -> f64

Source§

fn mul(self, other: f64) -> f64

Source§

fn div(self, other: f64) -> Result<f64, TrapCode>

Source§

impl ArithmeticOps<i32> for i32

Source§

fn add(self, other: i32) -> i32

Source§

fn sub(self, other: i32) -> i32

Source§

fn mul(self, other: i32) -> i32

Source§

fn div(self, other: i32) -> Result<i32, TrapCode>

Source§

impl ArithmeticOps<i64> for i64

Source§

fn add(self, other: i64) -> i64

Source§

fn sub(self, other: i64) -> i64

Source§

fn mul(self, other: i64) -> i64

Source§

fn div(self, other: i64) -> Result<i64, TrapCode>

Source§

impl ArithmeticOps<u32> for u32

Source§

fn add(self, other: u32) -> u32

Source§

fn sub(self, other: u32) -> u32

Source§

fn mul(self, other: u32) -> u32

Source§

fn div(self, other: u32) -> Result<u32, TrapCode>

Source§

impl ArithmeticOps<u64> for u64

Source§

fn add(self, other: u64) -> u64

Source§

fn sub(self, other: u64) -> u64

Source§

fn mul(self, other: u64) -> u64

Source§

fn div(self, other: u64) -> Result<u64, TrapCode>

Implementors§