Skip to content

Commit

Permalink
Auto merge of #43237 - zackmdavis:missing_sum_and_product_for_128_bit…
Browse files Browse the repository at this point in the history
…_integers, r=nagisa

add u128/i128 to sum/product implementors

Resolves #43235.
  • Loading branch information
bors committed Jul 16, 2017
2 parents be18613 + 30ad625 commit 8f1339a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/libcore/iter/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ macro_rules! float_sum_product {
)*)
}

integer_sum_product! { i8 i16 i32 i64 isize u8 u16 u32 u64 usize }
integer_sum_product! { i8 i16 i32 i64 i128 isize u8 u16 u32 u64 u128 usize }
float_sum_product! { f32 f64 }

/// An iterator adapter that produces output as long as the underlying
Expand Down
4 changes: 4 additions & 0 deletions src/test/run-pass/i128.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,8 @@ fn main() {
assert_eq!(b(-87559967289969187895646876466835277875_i128) /
b(84285771033834995895337664386045050880_i128),
-1i128);

// iter-arithmetic traits
assert_eq!(10i128, [1i128, 2, 3, 4].iter().sum());
assert_eq!(24i128, [1i128, 2, 3, 4].iter().product());
}
4 changes: 4 additions & 0 deletions src/test/run-pass/u128.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,8 @@ fn main() {
assert_eq!(b(0x679289ac23bb334f_36144401cf882172_u128) /
b(0x7b0b271b64865f05_f54a7b72746c062f_u128),
0u128);

// iter-arithmetic traits
assert_eq!(10u128, [1u128, 2, 3, 4].iter().sum());
assert_eq!(24u128, [1u128, 2, 3, 4].iter().product());
}

0 comments on commit 8f1339a

Please sign in to comment.