From 1f66f67791762e3d2bde0f823b3db94f69c0b8cf Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 14 May 2016 19:12:13 +0200 Subject: [PATCH] Replaced unwrap() by matching --- libimagstore/src/store.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/libimagstore/src/store.rs b/libimagstore/src/store.rs index b9c727fc..4b30a025 100644 --- a/libimagstore/src/store.rs +++ b/libimagstore/src/store.rs @@ -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.");