Skip to content

add u128/i128 to sum/product implementors #43237

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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());
}