From 8d9bd5154dc4373187f3dedd2abc7c613d847d3b Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 14 May 2016 19:17:44 +0200 Subject: [PATCH] Remove unwrap() by matching, remove unneeded deref() --- libimagstore/src/store.rs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/libimagstore/src/store.rs b/libimagstore/src/store.rs index c346fea7..b853b594 100644 --- a/libimagstore/src/store.rs +++ b/libimagstore/src/store.rs @@ -512,15 +512,13 @@ impl Store { id: &StoreId) -> Result<()> { - let guard = aspects.deref().lock(); - if guard.is_err() { return Err(SE::new(SEK::PreHookExecuteError, None)) } - - guard.unwrap().deref().iter() - .fold(Ok(()), |acc, aspect| { - debug!("[Aspect][exec]: {:?}", aspect); - acc.and_then(|_| (aspect as &StoreIdAccessor).access(id)) - }) - .map_err(|e| SE::new(SEK::PreHookExecuteError, Some(Box::new(e)))) + match aspects.lock() { + Err(_) => return Err(SE::new(SEK::PreHookExecuteError, None)), + Ok(g) => g + }.iter().fold(Ok(()), |acc, aspect| { + debug!("[Aspect][exec]: {:?}", aspect); + acc.and_then(|_| (aspect as &StoreIdAccessor).access(id)) + }).map_err(|e| SE::new(SEK::PreHookExecuteError, Some(Box::new(e)))) } fn execute_hooks_for_mut_file(&self,