std-type

Wrapping<T>

Use a numeric wrapper when a sequence of supported arithmetic operations should wrap. Extract the inner integer with .0. Expected stdout (not executed): 1 Common mistake: Assuming division by zero becomes valid when wrapped.

Formal Syntax & Structure

rust syntaxrust
Wrapping(value) + Wrapping(other)

Working Example

Example Snippetrust
fn main() {    use std::num::Wrapping;    let mut index = Wrapping(254u8);    index += Wrapping(3);    println!("{}", index.0);}
Rust Reference