std-method

Integer wrapping_mul and wrapping_pow

Compute arithmetic modulo the bit width’s power of two; useful for intentionally bounded checksums or sequence calculations. Expected stdout (not executed): 144 0 Common mistake: Assuming this produces a cryptographic checksum or an exact product.

Formal Syntax & Structure

rust syntaxrust
x.wrapping_mul(y); x.wrapping_pow(exp)

Working Example

Example Snippetrust
fn main() {    println!("{} {}", 20u8.wrapping_mul(20), 2u8.wrapping_pow(8));}
Rust Reference