diff --git a/example/std_example.rs b/example/std_example.rs index bd51a37f29f..a09e050ce3b 100644 --- a/example/std_example.rs +++ b/example/std_example.rs @@ -34,8 +34,8 @@ fn main() { assert_eq!(0b0000000000000000000000000010000010000000000000000000000000000000_0000000000100000000000000000000000001000000000000100000000000000u128.leading_zeros(), 26); assert_eq!(0b0000000000000000000000000010000000000000000000000000000000000000_0000000000000000000000000000000000001000000000000000000010000000u128.trailing_zeros(), 7); - checked_div_i128(0i128, 2i128); - checked_div_u128(0u128, 2u128); + 0i128.checked_div(2i128); + 0u128.checked_div(2u128); assert_eq!(1u128 + 2, 3); assert_eq!(0b100010000000000000000000000000000u128 >> 10, 0b10001000000000000000000u128); @@ -61,18 +61,3 @@ fn map(a: Option<(u8, Box)>) -> Option> { Some((_, instr)) => Some(instr), } } - -fn checked_div_i128(lhs: i128, rhs: i128) -> Option { - if rhs == 0 || (lhs == -170141183460469231731687303715884105728 && rhs == -1) { - None - } else { - Some(unsafe { intrinsics::unchecked_div(lhs, rhs) }) - } -} - -fn checked_div_u128(lhs: u128, rhs: u128) -> Option { - match rhs { - 0 => None, - rhs => Some(unsafe { intrinsics::unchecked_div(lhs, rhs) }) - } -}