replace match by ok()

This commit is contained in:
Ralf Jung 2019-07-28 22:30:19 +02:00
parent c119291b55
commit 0e602f10b5

View file

@ -57,18 +57,12 @@ pub trait AllocMap<K: Hash + Eq, V> {
/// Read-only lookup.
fn get(&self, k: K) -> Option<&V> {
match self.get_or(k, || Err(())) {
Ok(v) => Some(v),
Err(()) => None,
}
self.get_or(k, || Err(())).ok()
}
/// Mutable lookup.
fn get_mut(&mut self, k: K) -> Option<&mut V> {
match self.get_mut_or(k, || Err(())) {
Ok(v) => Some(v),
Err(()) => None,
}
self.get_mut_or(k, || Err(())).ok()
}
}