Skip to main content

WrappingAbs

Trait WrappingAbs 

Source
pub trait WrappingAbs: Sized + Neg {
    // Required method
    fn wrapping_abs(self) -> <Self as Neg>::Output;
}
Expand description

Computes the absolute value, wrapping around on overflow.

Required Methods§

Source

fn wrapping_abs(self) -> <Self as Neg>::Output

Wrapping (modular) absolute value. Computes self.abs(), wrapping around at the boundary of the type. The only wrapping case is MIN.wrapping_abs() == MIN.

use const_num_traits::WrappingAbs;

assert_eq!(WrappingAbs::wrapping_abs(-100i8), 100);
assert_eq!(WrappingAbs::wrapping_abs(i8::MIN), i8::MIN); // 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 WrappingAbs for i8

Source§

impl WrappingAbs for i16

Source§

impl WrappingAbs for i32

Source§

impl WrappingAbs for i64

Source§

impl WrappingAbs for i128

Source§

impl WrappingAbs for isize

Implementors§