about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorJosh Stone <jistone@redhat.com>2020-04-07 16:50:26 -0700
committerJosh Stone <jistone@redhat.com>2020-04-07 16:50:26 -0700
commit2c4cffde3bdc36d9634ebf24e512f19aa6fe1ccb (patch)
treeee57a509eda48126285791ccbe82ee4048c92b52 /src/libcore
parent8aac1077ed495ef8d1241ce76d4b64d7eb13a856 (diff)
downloadrust-2c4cffde3bdc36d9634ebf24e512f19aa6fe1ccb.tar.gz
rust-2c4cffde3bdc36d9634ebf24e512f19aa6fe1ccb.zip
Reduce callsites in Chain::last()
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/iter/adapters/chain.rs21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/libcore/iter/adapters/chain.rs b/src/libcore/iter/adapters/chain.rs
index 0100e62fae6..aadecdfbb65 100644
--- a/src/libcore/iter/adapters/chain.rs
+++ b/src/libcore/iter/adapters/chain.rs
@@ -130,17 +130,16 @@ where
 
     #[inline]
     fn last(self) -> Option<A::Item> {
-        match self {
-            Chain { a: Some(a), b: Some(b) } => {
-                // Must exhaust a before b.
-                let a_last = a.last();
-                let b_last = b.last();
-                b_last.or(a_last)
-            }
-            Chain { a: Some(a), b: None } => a.last(),
-            Chain { a: None, b: Some(b) } => b.last(),
-            Chain { a: None, b: None } => None,
-        }
+        // Must exhaust a before b.
+        let a_last = match self.a {
+            Some(a) => a.last(),
+            None => None,
+        };
+        let b_last = match self.b {
+            Some(b) => b.last(),
+            None => None,
+        };
+        b_last.or(a_last)
     }
 
     #[inline]