Fix clippy::map_entry

This commit is contained in:
Luis Moreno
2020-11-10 00:36:54 -04:00
parent d620f225ee
commit 18df9c758c
2 changed files with 6 additions and 6 deletions
-1
View File
@@ -67,7 +67,6 @@
#![allow( #![allow(
clippy::needless_range_loop, clippy::needless_range_loop,
clippy::ptr_arg, clippy::ptr_arg,
clippy::map_entry,
clippy::type_complexity, clippy::type_complexity,
clippy::too_many_arguments, clippy::too_many_arguments,
clippy::many_single_char_names clippy::many_single_char_names
+6 -5
View File
@@ -300,11 +300,12 @@ impl<'a, T: RealNumber, M: Matrix<T>, K: Kernel<T, M::RowVector>> Cache<'a, T, M
fn get(&mut self, i: &SupportVector<T, M::RowVector>, j: &SupportVector<T, M::RowVector>) -> T { fn get(&mut self, i: &SupportVector<T, M::RowVector>, j: &SupportVector<T, M::RowVector>) -> T {
let idx_i = i.index; let idx_i = i.index;
let idx_j = j.index; let idx_j = j.index;
if !self.data.contains_key(&(idx_i, idx_j)) { #[allow(clippy::or_fun_call)]
let v = self.kernel.apply(&i.x, &j.x); let entry = self
self.data.insert((idx_i, idx_j), v); .data
} .entry((idx_i, idx_j))
*self.data.get(&(idx_i, idx_j)).unwrap() .or_insert(self.kernel.apply(&i.x, &j.x));
*entry
} }
fn insert(&mut self, key: (usize, usize), value: T) { fn insert(&mut self, key: (usize, usize), value: T) {