Auto merge of #28818 - Stebalien:fix-iter-chain-order, r=alexcrichton

part of #28810
This commit is contained in:
bors 2015-10-03 06:03:50 +00:00
commit f492ec4bf4

View file

@ -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()
}