Reduce boilerplate with the ?
operator
This commit is contained in:
parent
c643dd2ec8
commit
e0871cc0be
@ -649,17 +649,13 @@ pub mod shell {
|
||||
impl<'a> Iterator for Substitutions<'a> {
|
||||
type Item = Substitution<'a>;
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
match parse_next_substitution(self.s) {
|
||||
Some((mut sub, tail)) => {
|
||||
self.s = tail;
|
||||
if let Some(InnerSpan { start, end }) = sub.position() {
|
||||
sub.set_position(start + self.pos, end + self.pos);
|
||||
self.pos += end;
|
||||
}
|
||||
Some(sub)
|
||||
}
|
||||
None => None,
|
||||
let (mut sub, tail) = parse_next_substitution(self.s)?;
|
||||
self.s = tail;
|
||||
if let Some(InnerSpan { start, end }) = sub.position() {
|
||||
sub.set_position(start + self.pos, end + self.pos);
|
||||
self.pos += end;
|
||||
}
|
||||
Some(sub)
|
||||
}
|
||||
|
||||
fn size_hint(&self) -> (usize, Option<usize>) {
|
||||
|
@ -2364,13 +2364,9 @@ impl<'o, 'tcx> Iterator for TraitObligationStackList<'o, 'tcx> {
|
||||
type Item = &'o TraitObligationStack<'o, 'tcx>;
|
||||
|
||||
fn next(&mut self) -> Option<&'o TraitObligationStack<'o, 'tcx>> {
|
||||
match self.head {
|
||||
Some(o) => {
|
||||
*self = o.previous;
|
||||
Some(o)
|
||||
}
|
||||
None => None,
|
||||
}
|
||||
let o = self.head?;
|
||||
*self = o.previous;
|
||||
Some(o)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user