From 63c5a2e58f6a03835ad12690b58b3874be31f1a0 Mon Sep 17 00:00:00 2001 From: Nikolay Volf Date: Fri, 19 Feb 2016 14:52:29 +0300 Subject: [PATCH] copy instead of ref-map --- util/src/keys/directory.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/util/src/keys/directory.rs b/util/src/keys/directory.rs index 9c01d1974..67bf8cbc1 100644 --- a/util/src/keys/directory.rs +++ b/util/src/keys/directory.rs @@ -473,7 +473,7 @@ impl KeyDirectory { /// Returns key given by id if corresponding file exists and no load error occured. /// Warns if any error occured during the key loading - pub fn get(&self, id: &Uuid) -> Option> { + pub fn get(&self, id: &Uuid) -> Option { let path = self.key_path(id); { let mut usage = self.cache_usage.borrow_mut(); @@ -492,7 +492,10 @@ impl KeyDirectory { } } - Some(Ref::map(self.cache.borrow(), |c| c.get(id).expect("should be they key, we have just inserted or checked it"))) + // todo: replace with Ref::map when it stabilized to avoid copies + Some(self.cache.borrow().get(id) + .expect("should be they key, we have just inserted or checked it") + .clone()) } /// Returns current path to the directory with keys