From 1faa9d6016088d10b071b917a164b4b6c8ff2e1d Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 4 Jul 2019 15:20:27 +0300 Subject: [PATCH] remove needless clone --- src/input.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/input.rs b/src/input.rs index 00c1db0..6438f9b 100644 --- a/src/input.rs +++ b/src/input.rs @@ -140,10 +140,9 @@ where DB: Database, { fn try_fetch(&self, db: &DB, key: &Q::Key) -> Result { - let slot = match self.slot(key) { - Some(s) => s.clone(), - None => panic!("no value set for {:?}({:?})", Q::default(), key), - }; + let slot = self.slot(key).unwrap_or_else(|| { + panic!("no value set for {:?}({:?})", Q::default(), key) + }); let StampedValue { value, changed_at } = slot.stamped_value.read().clone();