Reduce callsites in Chain::last()
This commit is contained in:
parent
8aac1077ed
commit
2c4cffde3b
@ -130,17 +130,16 @@ fn find<P>(&mut self, mut predicate: P) -> Option<Self::Item>
|
||||
|
||||
#[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]
|
||||
|
Loading…
Reference in New Issue
Block a user