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
/// it is not public.
fn _update<'a>(&'a self, entry: &FileLockEntry<'a>) -> Result<()> {
let hsmap = self.entries.write();
if hsmap.is_err() {
return Err(SE::new(SEK::LockPoisoned, None))
}
let mut hsmap = hsmap.unwrap();
let mut se = try!(hsmap.get_mut(&entry.key)
.ok_or(SE::new(SEK::IdNotFound, None)));
let mut hsmap = match self.entries.write() {
Err(_) => return Err(SE::new(SEK::LockPoisoned, None)),
Ok(e) => e,
};
let mut se = try!(hsmap.get_mut(&entry.key).ok_or(SE::new(SEK::IdNotFound, None)));
assert!(se.is_borrowed(), "Tried to update a non borrowed entry.");