From 3fb6d507e509813f57750db419d19f74c68d1e1f Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 14 May 2016 19:05:11 +0200 Subject: [PATCH] Remove unwrap() by matching --- libimagstore/src/store.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libimagstore/src/store.rs b/libimagstore/src/store.rs index 0224eb77..0ba28816 100644 --- a/libimagstore/src/store.rs +++ b/libimagstore/src/store.rs @@ -302,11 +302,11 @@ impl Store { return Err(e); } - let hsmap = self.entries.write(); - if hsmap.is_err() { - return Err(StoreError::new(StoreErrorKind::LockPoisoned, None)) - } - let mut hsmap = hsmap.unwrap(); + let mut hsmap = match self.entries.write() { + Err(_) => return Err(StoreError::new(StoreErrorKind::LockPoisoned, None)), + Ok(s) => s, + }; + if hsmap.contains_key(&id) { return Err(StoreError::new(StoreErrorKind::EntryAlreadyExists, None)) }