Skip to content

Commit

Permalink
CR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
scottmcm committed Nov 5, 2017
1 parent eef4d42 commit b5dba91
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/libcore/iter/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1372,7 +1372,7 @@ pub trait Iterator {
/// #![feature(iterator_try_fold)]
/// let a = [1, 2, 3];
///
/// // the checked sum of all of the elements of a
/// // the checked sum of all of the elements of the array
/// let sum = a.iter()
/// .try_fold(0i8, |acc, &x| acc.checked_add(x));
///
Expand Down Expand Up @@ -1431,7 +1431,7 @@ pub trait Iterator {
/// ```
/// let a = [1, 2, 3];
///
/// // the sum of all of the elements of a
/// // the sum of all of the elements of the array
/// let sum = a.iter()
/// .fold(0, |acc, &x| acc + x);
///
Expand Down
14 changes: 4 additions & 10 deletions src/libcore/iter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -786,11 +786,8 @@ impl<A, B> Iterator for Chain<A, B> where
}
_ => { }
}
match self.state {
ChainState::Both | ChainState::Back => {
accum = self.b.try_fold(accum, &mut f)?;
}
_ => { }
if let ChainState::Back = self.state {
accum = self.b.try_fold(accum, &mut f)?;
}
Try::from_ok(accum)
}
Expand Down Expand Up @@ -917,11 +914,8 @@ impl<A, B> DoubleEndedIterator for Chain<A, B> where
}
_ => { }
}
match self.state {
ChainState::Both | ChainState::Front => {
accum = self.a.try_rfold(accum, &mut f)?;
}
_ => { }
if let ChainState::Front = self.state {
accum = self.a.try_rfold(accum, &mut f)?;
}
Try::from_ok(accum)
}
Expand Down

0 comments on commit b5dba91

Please sign in to comment.