From a80e8fea858ff789ed9fc490c2c1eb2b4eed6e82 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Tue, 30 Jun 2020 13:54:40 +0200 Subject: Simplify entry API usage --- crates/ra_hir_def/src/item_scope.rs | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) (limited to 'crates') diff --git a/crates/ra_hir_def/src/item_scope.rs b/crates/ra_hir_def/src/item_scope.rs index f36477c03..c8dde6f8d 100644 --- a/crates/ra_hir_def/src/item_scope.rs +++ b/crates/ra_hir_def/src/item_scope.rs @@ -158,31 +158,22 @@ impl ItemScope { let mut changed = false; if let Some(types) = def.types { - match self.types.entry(name.clone()) { - Entry::Occupied(_) => {} - Entry::Vacant(e) => { - e.insert(types); - changed = true; - } - } + self.types.entry(name.clone()).or_insert_with(|| { + changed = true; + types + }); } if let Some(values) = def.values { - match self.values.entry(name.clone()) { - Entry::Occupied(_) => {} - Entry::Vacant(e) => { - e.insert(values); - changed = true; - } - } + self.values.entry(name.clone()).or_insert_with(|| { + changed = true; + values + }); } if let Some(macros) = def.macros { - match self.macros.entry(name.clone()) { - Entry::Occupied(_) => {} - Entry::Vacant(e) => { - e.insert(macros); - changed = true; - } - } + self.macros.entry(name.clone()).or_insert_with(|| { + changed = true; + macros + }); } if def.is_none() { -- cgit v1.2.3