Skip to main content

WrappingRem

Trait WrappingRem 

Source
pub trait WrappingRem: Sized {
    type Output;

    // Required method
    fn wrapping_rem(self, v: Self) -> Self::Output;
}
Expand description

Performs a remainder operation that wraps around on overflow.

Required Associated Types§

Source

type Output

The result type (Self for the primitive impls).

Required Methods§

Source

fn wrapping_rem(self, v: Self) -> Self::Output

Wrapping (modular) remainder. Computes self % other, wrapping around at the boundary of the type.

The only case where such wrapping can occur is MIN % -1 on a signed type, where the remainder is defined to be 0. For unsigned types this is a normal remainder and can never wrap.

§Panics

Panics if other is zero.

use const_num_traits::WrappingRem;

assert_eq!(WrappingRem::wrapping_rem(100i8, 10), 0);
assert_eq!(WrappingRem::wrapping_rem(i8::MIN, -1), 0); // wrapped!

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

Source§

type Output = i8

Source§

fn wrapping_rem(self, v: Self) -> Self

Source§

impl WrappingRem for i16

Source§

type Output = i16

Source§

fn wrapping_rem(self, v: Self) -> Self

Source§

impl WrappingRem for i32

Source§

type Output = i32

Source§

fn wrapping_rem(self, v: Self) -> Self

Source§

impl WrappingRem for i64

Source§

type Output = i64

Source§

fn wrapping_rem(self, v: Self) -> Self

Source§

impl WrappingRem for i128

Source§

type Output = i128

Source§

fn wrapping_rem(self, v: Self) -> Self

Source§

impl WrappingRem for isize

Source§

type Output = isize

Source§

fn wrapping_rem(self, v: Self) -> Self

Source§

impl WrappingRem for u8

Source§

type Output = u8

Source§

fn wrapping_rem(self, v: Self) -> Self

Source§

impl WrappingRem for u16

Source§

type Output = u16

Source§

fn wrapping_rem(self, v: Self) -> Self

Source§

impl WrappingRem for u32

Source§

type Output = u32

Source§

fn wrapping_rem(self, v: Self) -> Self

Source§

impl WrappingRem for u64

Source§

type Output = u64

Source§

fn wrapping_rem(self, v: Self) -> Self

Source§

impl WrappingRem for u128

Source§

type Output = u128

Source§

fn wrapping_rem(self, v: Self) -> Self

Source§

impl WrappingRem for usize

Source§

type Output = usize

Source§

fn wrapping_rem(self, v: Self) -> Self

Implementors§