Skip to main content

Ops

Trait Ops 

Source
pub trait Ops: Copy {
    // Required methods
    fn unary(op: UnaryOp, x: Self) -> Self;
    fn binary(op: BinaryOp, x: Self, y: Self) -> Self;
    fn is_finite(x: Self) -> bool;
    fn lowest() -> Self;
    fn highest() -> Self;

    // Provided method
    fn ternary(op: TernaryOp, x: Self, y: Self, z: Self) -> Self { ... }
}
Expand description

Elementwise operations on one element type. Calling an operation that the type does not support (see UnaryOp::supports) panics; callers check the types first.

Required Methods§

Source

fn unary(op: UnaryOp, x: Self) -> Self

Applies a unary operation.

Source

fn binary(op: BinaryOp, x: Self, y: Self) -> Self

Applies a binary operation.

Source

fn is_finite(x: Self) -> bool

Returns whether the value is neither infinite nor NaN (always true for integers and booleans).

Source

fn lowest() -> Self

The smallest value (negative infinity for floats): the identity of max.

Source

fn highest() -> Self

The largest value (positive infinity for floats): the identity of min.

Provided Methods§

Source

fn ternary(op: TernaryOp, x: Self, y: Self, z: Self) -> Self

Applies a ternary operation (only floats support them).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Ops for bool

Source§

impl Ops for f32

Source§

impl Ops for f64

Source§

impl Ops for i8

Source§

impl Ops for i16

Source§

impl Ops for i32

Source§

impl Ops for i64

Source§

impl Ops for u8

Source§

impl Ops for u16

Source§

impl Ops for u32

Source§

impl Ops for u64

Implementors§