Skip to main content

OverflowingOp

Trait OverflowingOp 

Source
trait OverflowingOp: Sized {
    const ONE_PASS: bool = true;

    // Required methods
    fn add_overflowing(self, rhs: Self) -> (Self, bool);
    fn sub_overflowing(self, rhs: Self) -> (Self, bool);
    fn mul_overflowing(self, rhs: Self) -> (Self, bool);
}
Expand description

Wrapping +, - and * that also report whether they overflowed, written so that LLVM vectorizes a loop over them.

The signed overflowing_add and overflowing_sub lower to llvm.sadd.with.overflow and llvm.ssub.with.overflow, which LLVM doesn’t vectorize, so the signed impls test the sign bits instead.

Provided Associated Constants§

Source

const ONE_PASS: bool = true

Whether the checked kernels use the one-pass path for this type. When it’s false, overflowing_op returns None without doing any work.

Required Methods§

Source

fn add_overflowing(self, rhs: Self) -> (Self, bool)

Source

fn sub_overflowing(self, rhs: Self) -> (Self, bool)

Source

fn mul_overflowing(self, rhs: Self) -> (Self, bool)

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 OverflowingOp for i8

Source§

fn add_overflowing(self, rhs: Self) -> (Self, bool)

Source§

fn sub_overflowing(self, rhs: Self) -> (Self, bool)

Source§

fn mul_overflowing(self, rhs: Self) -> (Self, bool)

Source§

impl OverflowingOp for i16

Source§

fn add_overflowing(self, rhs: Self) -> (Self, bool)

Source§

fn sub_overflowing(self, rhs: Self) -> (Self, bool)

Source§

fn mul_overflowing(self, rhs: Self) -> (Self, bool)

Source§

impl OverflowingOp for i32

Source§

fn add_overflowing(self, rhs: Self) -> (Self, bool)

Source§

fn sub_overflowing(self, rhs: Self) -> (Self, bool)

Source§

fn mul_overflowing(self, rhs: Self) -> (Self, bool)

Source§

impl OverflowingOp for i64

Source§

fn add_overflowing(self, rhs: Self) -> (Self, bool)

Source§

fn sub_overflowing(self, rhs: Self) -> (Self, bool)

Source§

fn mul_overflowing(self, rhs: Self) -> (Self, bool)

Source§

impl OverflowingOp for i128

Source§

fn add_overflowing(self, rhs: Self) -> (Self, bool)

Source§

fn sub_overflowing(self, rhs: Self) -> (Self, bool)

Source§

fn mul_overflowing(self, rhs: Self) -> (Self, bool)

Source§

impl OverflowingOp for i256

Source§

const ONE_PASS: bool = false

Source§

fn add_overflowing(self, rhs: Self) -> (Self, bool)

Source§

fn sub_overflowing(self, rhs: Self) -> (Self, bool)

Source§

fn mul_overflowing(self, rhs: Self) -> (Self, bool)

Source§

impl OverflowingOp for u8

Source§

fn add_overflowing(self, rhs: Self) -> (Self, bool)

Source§

fn sub_overflowing(self, rhs: Self) -> (Self, bool)

Source§

fn mul_overflowing(self, rhs: Self) -> (Self, bool)

Source§

impl OverflowingOp for u16

Source§

fn add_overflowing(self, rhs: Self) -> (Self, bool)

Source§

fn sub_overflowing(self, rhs: Self) -> (Self, bool)

Source§

fn mul_overflowing(self, rhs: Self) -> (Self, bool)

Source§

impl OverflowingOp for u32

Source§

fn add_overflowing(self, rhs: Self) -> (Self, bool)

Source§

fn sub_overflowing(self, rhs: Self) -> (Self, bool)

Source§

fn mul_overflowing(self, rhs: Self) -> (Self, bool)

Source§

impl OverflowingOp for u64

Source§

fn add_overflowing(self, rhs: Self) -> (Self, bool)

Source§

fn sub_overflowing(self, rhs: Self) -> (Self, bool)

Source§

fn mul_overflowing(self, rhs: Self) -> (Self, bool)

Implementors§