Skip to content

Commit

Permalink
libcore: Chain must exhaust a before b.
Browse files Browse the repository at this point in the history
part of #28810
  • Loading branch information
Stebalien committed Oct 2, 2015
1 parent ef07d7d commit 6999c42
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/libcore/iter.rs
Expand Up @@ -1559,7 +1559,12 @@ impl<A, B> Iterator for Chain<A, B> where
#[inline]
fn last(self) -> Option<A::Item> {
match self.state {
ChainState::Both => self.b.last().or(self.a.last()),
ChainState::Both => {
// Must exhaust a before b.
let a_last = self.a.last();
let b_last = self.b.last();
b_last.or(a_last)
},
ChainState::Front => self.a.last(),
ChainState::Back => self.b.last()
}
Expand Down

0 comments on commit 6999c42

Please sign in to comment.