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

@ -153,10 +153,7 @@ where
K: Borrow<Q>,
Q: PrecomputedHash + Hash + Eq,
{
let index = match self.index.iter().position(|k| k.borrow() == key) {
Some(p) => p,
None => return None,
};
let index = self.index.iter().position(|k| k.borrow() == key)?;
self.index.remove(index);
self.values.remove(key)
}
@ -194,10 +191,7 @@ where
type Item = (&'a K, &'a V);
fn next(&mut self) -> Option<Self::Item> {
let key = match self.inner.index.get(self.pos) {
Some(k) => k,
None => return None,
};
let key = self.inner.index.get(self.pos)?;
self.pos += 1;
let value = &self.inner.values[key];