style: optimized ch13-02-iterators sample code

This commit is contained in:
YangFong 2022-03-01 20:08:55 +08:00
parent e3d20c06cb
commit d7a6edefc8

View File

@ -335,10 +335,11 @@ fn calling_next_directly() {
# #
#[test] #[test]
fn using_other_iterator_trait_methods() { fn using_other_iterator_trait_methods() {
let sum: u32 = Counter::new().zip(Counter::new().skip(1)) let sum: u32 = Counter::new()
.map(|(a, b)| a * b) .zip(Counter::new().skip(1))
.filter(|x| x % 3 == 0) .map(|(a, b)| a * b)
.sum(); .filter(|x| x % 3 == 0)
.sum();
assert_eq!(18, sum); assert_eq!(18, sum);
} }
``` ```