3 releases (breaking)

Uses old Rust 2015

0.3.0 Aug 29, 2018
0.2.0 May 27, 2017
0.1.0 May 27, 2017

#1102 in Math

MIT/Apache

6KB
93 lines

Provides a macro allow natural usage of checked math.

Documentation.

let a = 5u8;
let b = 20u8;
let z = 0u8;
 
checked_wrap![a, b, z];
 
assert_eq!(*(a + b), Some(25));
assert_eq!(*(b * b), None);
assert_eq!(*(a - b), None);
assert_eq!(*(b / z), None);
assert_eq!(*(a - 20), None);
assert_eq!(*((a - b) + 1), None);

Dependencies

~150KB