diff options
| author | bors <bors@rust-lang.org> | 2015-10-03 06:03:50 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-10-03 06:03:50 +0000 |
| commit | f492ec4bf4f2d8a69fd02ac186d1589bdfadd3bd (patch) | |
| tree | 5673f5a46f463880c51c60026c250e2d704ad3c1 /src/libcore | |
| parent | d2047bc97d43dcb6b3d968b9acba1ab4d2de892e (diff) | |
| parent | 6999c421ef7a80104c0799ce8d800a98d0ae85c0 (diff) | |
| download | rust-f492ec4bf4f2d8a69fd02ac186d1589bdfadd3bd.tar.gz rust-f492ec4bf4f2d8a69fd02ac186d1589bdfadd3bd.zip | |
Auto merge of #28818 - Stebalien:fix-iter-chain-order, r=alexcrichton
part of #28810
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/iter.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index abf50250dc2..bd24cd4609e 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -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() } |
