diff options
| author | Steven Allen <steven@stebalien.com> | 2015-10-02 18:41:06 -0400 |
|---|---|---|
| committer | Steven Allen <steven@stebalien.com> | 2015-10-02 18:41:06 -0400 |
| commit | 6999c421ef7a80104c0799ce8d800a98d0ae85c0 (patch) | |
| tree | e645a915ec11d288800eb9a888a1cdfef4e9996b | |
| parent | ef07d7dd40e33d7af95c7b00717503730ce69c11 (diff) | |
| download | rust-6999c421ef7a80104c0799ce8d800a98d0ae85c0.tar.gz rust-6999c421ef7a80104c0799ce8d800a98d0ae85c0.zip | |
libcore: Chain must exhaust a before b.
part of #28810
| -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() } |
