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§

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

Source§

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

Source§

fn is_finite(_: Self) -> bool

Source§

fn lowest() -> Self

Source§

fn highest() -> Self

Source§

impl Ops for f32

Source§

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

Source§

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

Source§

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

Source§

fn is_finite(x: Self) -> bool

Source§

fn lowest() -> Self

Source§

fn highest() -> Self

Source§

impl Ops for f64

Source§

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

Source§

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

Source§

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

Source§

fn is_finite(x: Self) -> bool

Source§

fn lowest() -> Self

Source§

fn highest() -> Self

Source§

impl Ops for i8

Source§

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

Source§

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

Source§

fn is_finite(_: Self) -> bool

Source§

fn lowest() -> Self

Source§

fn highest() -> Self

Source§

impl Ops for i16

Source§

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

Source§

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

Source§

fn is_finite(_: Self) -> bool

Source§

fn lowest() -> Self

Source§

fn highest() -> Self

Source§

impl Ops for i32

Source§

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

Source§

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

Source§

fn is_finite(_: Self) -> bool

Source§

fn lowest() -> Self

Source§

fn highest() -> Self

Source§

impl Ops for i64

Source§

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

Source§

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

Source§

fn is_finite(_: Self) -> bool

Source§

fn lowest() -> Self

Source§

fn highest() -> Self

Source§

impl Ops for u8

Source§

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

Source§

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

Source§

fn is_finite(_: Self) -> bool

Source§

fn lowest() -> Self

Source§

fn highest() -> Self

Source§

impl Ops for u16

Source§

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

Source§

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

Source§

fn is_finite(_: Self) -> bool

Source§

fn lowest() -> Self

Source§

fn highest() -> Self

Source§

impl Ops for u32

Source§

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

Source§

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

Source§

fn is_finite(_: Self) -> bool

Source§

fn lowest() -> Self

Source§

fn highest() -> Self

Source§

impl Ops for u64

Source§

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

Source§

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

Source§

fn is_finite(_: Self) -> bool

Source§

fn lowest() -> Self

Source§

fn highest() -> Self

Implementors§

Source§

impl Ops for bf16

Source§

impl Ops for c64

Source§

impl Ops for c128

Source§

impl Ops for f16