Replaced unwrap() by matching

This commit is contained in:
Matthias Beyer 2016-05-14 19:12:13 +02:00
parent 7b612ce8fb
commit 1f66f67791

View file

@ -386,13 +386,12 @@ impl Store {
/// This method assumes that entry is dropped _right after_ the call, hence /// This method assumes that entry is dropped _right after_ the call, hence
/// it is not public. /// it is not public.
fn _update<'a>(&'a self, entry: &FileLockEntry<'a>) -> Result<()> { fn _update<'a>(&'a self, entry: &FileLockEntry<'a>) -> Result<()> {
let hsmap = self.entries.write(); let mut hsmap = match self.entries.write() {
if hsmap.is_err() { Err(_) => return Err(SE::new(SEK::LockPoisoned, None)),
return Err(SE::new(SEK::LockPoisoned, None)) Ok(e) => e,
} };
let mut hsmap = hsmap.unwrap();
let mut se = try!(hsmap.get_mut(&entry.key) let mut se = try!(hsmap.get_mut(&entry.key).ok_or(SE::new(SEK::IdNotFound, None)));
.ok_or(SE::new(SEK::IdNotFound, None)));
assert!(se.is_borrowed(), "Tried to update a non borrowed entry."); assert!(se.is_borrowed(), "Tried to update a non borrowed entry.");