Skip to content

Commit 2c4cffd

Browse files
committed
Reduce callsites in Chain::last()
1 parent 8aac107 commit 2c4cffd

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

src/libcore/iter/adapters/chain.rs

+10-11
Original file line numberDiff line numberDiff line change
@@ -130,17 +130,16 @@ where
130130

131131
#[inline]
132132
fn last(self) -> Option<A::Item> {
133-
match self {
134-
Chain { a: Some(a), b: Some(b) } => {
135-
// Must exhaust a before b.
136-
let a_last = a.last();
137-
let b_last = b.last();
138-
b_last.or(a_last)
139-
}
140-
Chain { a: Some(a), b: None } => a.last(),
141-
Chain { a: None, b: Some(b) } => b.last(),
142-
Chain { a: None, b: None } => None,
143-
}
133+
// Must exhaust a before b.
134+
let a_last = match self.a {
135+
Some(a) => a.last(),
136+
None => None,
137+
};
138+
let b_last = match self.b {
139+
Some(b) => b.last(),
140+
None => None,
141+
};
142+
b_last.or(a_last)
144143
}
145144

146145
#[inline]

0 commit comments

Comments
 (0)