Signature
Examples
Trait functions
wrapping_add
Wrapping (modular) addition. Computesself + other, wrapping around at the boundary of the
type.
pub trait WrappingAdd
use core::num::traits::WrappingAdd;
let result = 255_u8.wrapping_add(1);
assert!(result == 0);
let result = 100_u8.wrapping_add(200);
assert!(result == 44); // (100 + 200) % 256 = 44
self + other, wrapping around at the boundary of the
type.
fn wrapping_add(self: T, v: T) -> T
Was this page helpful?