mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-08 01:28:18 +03:00
Auto merge of #28818 - Stebalien:fix-iter-chain-order, r=alexcrichton
part of #28810
This commit is contained in:
+6
-1
@@ -1559,7 +1559,12 @@ fn nth(&mut self, mut n: usize) -> Option<A::Item> {
|
||||
#[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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user