style: Use the ? operator for Option

This commit is contained in:
Matt Brubeck 2017-12-08 16:53:17 -08:00
parent c52d347022
commit 3005a26daf
13 changed files with 47 additions and 129 deletions

View file

@ -89,10 +89,7 @@ impl Iterator for OriginSetIterator {
fn next(&mut self) -> Option<Origin> {
loop {
let origin = match Origin::from_index(self.cur) {
Some(origin) => origin,
None => return None,
};
let origin = Origin::from_index(self.cur)?;
self.cur += 1;
@ -184,10 +181,7 @@ impl<'a, T> Iterator for PerOriginIter<'a, T> where T: 'a {
type Item = (&'a T, Origin);
fn next(&mut self) -> Option<Self::Item> {
let origin = match Origin::from_index(self.cur) {
Some(origin) => origin,
None => return None,
};
let origin = Origin::from_index(self.cur)?;
self.cur += if self.rev { -1 } else { 1 };
@ -211,10 +205,7 @@ impl<'a, T> Iterator for PerOriginIterMut<'a, T> where T: 'a {
type Item = (&'a mut T, Origin);
fn next(&mut self) -> Option<Self::Item> {
let origin = match Origin::from_index(self.cur) {
Some(origin) => origin,
None => return None,
};
let origin = Origin::from_index(self.cur)?;
self.cur += 1;