From a481200c9ae4f14d1816ed6cd685acddde15219b Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 14 May 2016 19:15:51 +0200 Subject: [PATCH] Replace unwrap() by matching --- libimagstore/src/store.rs | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/libimagstore/src/store.rs b/libimagstore/src/store.rs index 964730be..c346fea7 100644 --- a/libimagstore/src/store.rs +++ b/libimagstore/src/store.rs @@ -474,16 +474,11 @@ impl Store { HookPosition::PostDelete => self.post_delete_aspects.clone(), }; - let guard = guard - .deref() - .lock() - .map_err(|_| SE::new(SEK::LockError, None)); + let mut guard = match guard.deref().lock().map_err(|_| SE::new(SEK::LockError, None)) { + Err(e) => return Err(SE::new(SEK::HookRegisterError, Some(Box::new(e)))), + Ok(g) => g, + }; - if guard.is_err() { - return Err(SE::new(SEK::HookRegisterError, - Some(Box::new(guard.err().unwrap())))); - } - let mut guard = guard.unwrap(); for mut aspect in guard.deref_mut() { if aspect.name().clone() == aspect_name.clone() { self.get_config_for_hook(h.name()).map(|config| h.set_config(config));