Skip to content

Commit b5dba91

Browse files
committed
CR feedback
1 parent eef4d42 commit b5dba91

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

src/libcore/iter/iterator.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1372,7 +1372,7 @@ pub trait Iterator {
13721372
/// #![feature(iterator_try_fold)]
13731373
/// let a = [1, 2, 3];
13741374
///
1375-
/// // the checked sum of all of the elements of a
1375+
/// // the checked sum of all of the elements of the array
13761376
/// let sum = a.iter()
13771377
/// .try_fold(0i8, |acc, &x| acc.checked_add(x));
13781378
///
@@ -1431,7 +1431,7 @@ pub trait Iterator {
14311431
/// ```
14321432
/// let a = [1, 2, 3];
14331433
///
1434-
/// // the sum of all of the elements of a
1434+
/// // the sum of all of the elements of the array
14351435
/// let sum = a.iter()
14361436
/// .fold(0, |acc, &x| acc + x);
14371437
///

src/libcore/iter/mod.rs

+4-10
Original file line numberDiff line numberDiff line change
@@ -786,11 +786,8 @@ impl<A, B> Iterator for Chain<A, B> where
786786
}
787787
_ => { }
788788
}
789-
match self.state {
790-
ChainState::Both | ChainState::Back => {
791-
accum = self.b.try_fold(accum, &mut f)?;
792-
}
793-
_ => { }
789+
if let ChainState::Back = self.state {
790+
accum = self.b.try_fold(accum, &mut f)?;
794791
}
795792
Try::from_ok(accum)
796793
}
@@ -917,11 +914,8 @@ impl<A, B> DoubleEndedIterator for Chain<A, B> where
917914
}
918915
_ => { }
919916
}
920-
match self.state {
921-
ChainState::Both | ChainState::Front => {
922-
accum = self.a.try_rfold(accum, &mut f)?;
923-
}
924-
_ => { }
917+
if let ChainState::Front = self.state {
918+
accum = self.a.try_rfold(accum, &mut f)?;
925919
}
926920
Try::from_ok(accum)
927921
}

0 commit comments

Comments
 (0)