mirror of
https://github.com/rust-lang-cn/book-cn.git
synced 2025-01-23 07:20:20 +08:00
style: optimized ch13-02-iterators sample code
This commit is contained in:
parent
e3d20c06cb
commit
d7a6edefc8
@ -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);
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
Loading…
Reference in New Issue
Block a user