Reduce callsites in Chain::count()

This commit is contained in:
Josh Stone 2020-04-07 16:50:16 -07:00
parent 859b8da21f
commit 8aac1077ed

View File

@ -62,12 +62,15 @@ fn next(&mut self) -> Option<A::Item> {
#[inline]
#[rustc_inherit_overflow_checks]
fn count(self) -> usize {
match self {
Chain { a: Some(a), b: Some(b) } => a.count() + b.count(),
Chain { a: Some(a), b: None } => a.count(),
Chain { a: None, b: Some(b) } => b.count(),
Chain { a: None, b: None } => 0,
}
let a_count = match self.a {
Some(a) => a.count(),
None => 0,
};
let b_count = match self.b {
Some(b) => b.count(),
None => 0,
};
a_count + b_count
}
fn try_fold<Acc, F, R>(&mut self, mut acc: Acc, mut f: F) -> R