const-int-wrapping.rs += wrapping_neg

This commit is contained in:
Lokathor 2019-02-01 18:55:38 -07:00
parent 5256efb800
commit 31bf7e1b51

View File

@ -13,6 +13,9 @@ const SHL_B: u32 = 1u32.wrapping_shl(128);
const SHR_A: u32 = 128u32.wrapping_shr(7);
const SHR_B: u32 = 128u32.wrapping_shr(128);
const NEG_A: u32 = 5u32.wrapping_neg();
const NEG_B: u32 = 1234567890u32.wrapping_neg();
fn ident<T>(ident: T) -> T {
ident
}
@ -30,6 +33,6 @@ fn main() {
assert_eq!(SHL_A, ident(128));
assert_eq!(SHL_B, ident(1));
assert_eq!(SHR_A, ident(1));
assert_eq!(SHR_B, ident(128));
assert_eq!(SHR_A, ident(4294967291));
assert_eq!(SHR_B, ident(3060399406));
}