Skip to content

Commit 01e2062

Browse files
set_from: use zip
Co-Authored-By: Jack Wrenn <[email protected]>
1 parent 1131899 commit 01e2062

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

src/lib.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2222,15 +2222,10 @@ pub trait Itertools: Iterator {
22222222
Self: Iterator<Item = &'a mut A>,
22232223
J: IntoIterator<Item = A>,
22242224
{
2225-
let mut count = 0;
2226-
for elt in from {
2227-
match self.next() {
2228-
None => break,
2229-
Some(ptr) => *ptr = elt,
2230-
}
2231-
count += 1;
2232-
}
2233-
count
2225+
from.into_iter()
2226+
.zip(self)
2227+
.map(|(new, old)| *old = new)
2228+
.count()
22342229
}
22352230

22362231
/// Combine all iterator elements into one String, separated by `sep`.

0 commit comments

Comments
 (0)