1
Fork 0

Rollup merge of #79325 - LingMan:try_op, r=jonas-schievink

Reduce boilerplate with the `?` operator

`@rustbot` modify labels to +C-cleanup.
This commit is contained in:
Jonas Schievink 2020-11-23 15:25:47 +01:00 committed by GitHub
commit b4db342f51
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 17 deletions

View file

@ -649,8 +649,7 @@ pub mod shell {
impl<'a> Iterator for Substitutions<'a> { impl<'a> Iterator for Substitutions<'a> {
type Item = Substitution<'a>; type Item = Substitution<'a>;
fn next(&mut self) -> Option<Self::Item> { fn next(&mut self) -> Option<Self::Item> {
match parse_next_substitution(self.s) { let (mut sub, tail) = parse_next_substitution(self.s)?;
Some((mut sub, tail)) => {
self.s = tail; self.s = tail;
if let Some(InnerSpan { start, end }) = sub.position() { if let Some(InnerSpan { start, end }) = sub.position() {
sub.set_position(start + self.pos, end + self.pos); sub.set_position(start + self.pos, end + self.pos);
@ -658,9 +657,6 @@ pub mod shell {
} }
Some(sub) Some(sub)
} }
None => None,
}
}
fn size_hint(&self) -> (usize, Option<usize>) { fn size_hint(&self) -> (usize, Option<usize>) {
(0, Some(self.s.len())) (0, Some(self.s.len()))

View file

@ -2372,14 +2372,10 @@ impl<'o, 'tcx> Iterator for TraitObligationStackList<'o, 'tcx> {
type Item = &'o TraitObligationStack<'o, 'tcx>; type Item = &'o TraitObligationStack<'o, 'tcx>;
fn next(&mut self) -> Option<&'o TraitObligationStack<'o, 'tcx>> { fn next(&mut self) -> Option<&'o TraitObligationStack<'o, 'tcx>> {
match self.head { let o = self.head?;
Some(o) => {
*self = o.previous; *self = o.previous;
Some(o) Some(o)
} }
None => None,
}
}
} }
impl<'o, 'tcx> fmt::Debug for TraitObligationStack<'o, 'tcx> { impl<'o, 'tcx> fmt::Debug for TraitObligationStack<'o, 'tcx> {