mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-24 07:44:10 +00:00
15 lines
487 B
Rust
15 lines
487 B
Rust
// run-pass
|
|
// compile-flags: -C debug_assertions=no
|
|
|
|
fn main() {
|
|
assert_eq!([1i32, i32::MAX].iter().sum::<i32>(),
|
|
1i32.wrapping_add(i32::MAX));
|
|
assert_eq!([2i32, i32::MAX].iter().product::<i32>(),
|
|
2i32.wrapping_mul(i32::MAX));
|
|
|
|
assert_eq!([1i32, i32::MAX].iter().cloned().sum::<i32>(),
|
|
1i32.wrapping_add(i32::MAX));
|
|
assert_eq!([2i32, i32::MAX].iter().cloned().product::<i32>(),
|
|
2i32.wrapping_mul(i32::MAX));
|
|
}
|