Performs subtraction that wraps around on overflow.

Signature

pub trait WrappingSub

Examples

use core::num::traits::WrappingSub;

let result = 0_u8.wrapping_sub(1);
assert!(result == 255);

let result = 100_u8.wrapping_sub(150);
assert!(result == 206);

Trait functions

wrapping_sub

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

Signature

fn wrapping_sub(self: T, v: T) -> T