about summary refs log tree commit diff
path: root/compiler/rustc_data_structures/src/sso/map.rs
diff options
context:
space:
mode:
authorClemens Wasser <clemens.wasser@gmail.com>2021-10-09 20:44:22 +0200
committerClemens Wasser <clemens.wasser@gmail.com>2021-10-10 15:38:19 +0200
commit71dd0b928b8b175b69e56fc58e5878b73f090718 (patch)
treeaeffddc5806cdc0d8b3d866d13c6235385b876a5 /compiler/rustc_data_structures/src/sso/map.rs
parent15491d7b6be1065217e09bd735e4ecffbe9838ba (diff)
downloadrust-71dd0b928b8b175b69e56fc58e5878b73f090718.tar.gz
rust-71dd0b928b8b175b69e56fc58e5878b73f090718.zip
Apply clippy suggestions
Diffstat (limited to 'compiler/rustc_data_structures/src/sso/map.rs')
-rw-r--r--compiler/rustc_data_structures/src/sso/map.rs16
1 files changed, 4 insertions, 12 deletions
diff --git a/compiler/rustc_data_structures/src/sso/map.rs b/compiler/rustc_data_structures/src/sso/map.rs
index 2de05cd4e56..d4274e99f1c 100644
--- a/compiler/rustc_data_structures/src/sso/map.rs
+++ b/compiler/rustc_data_structures/src/sso/map.rs
@@ -257,11 +257,7 @@ impl<K: Eq + Hash, V> SsoHashMap<K, V> {
     pub fn remove(&mut self, key: &K) -> Option<V> {
         match self {
             SsoHashMap::Array(array) => {
-                if let Some(index) = array.iter().position(|(k, _v)| k == key) {
-                    Some(array.swap_remove(index).1)
-                } else {
-                    None
-                }
+                array.iter().position(|(k, _v)| k == key).map(|index| array.swap_remove(index).1)
             }
             SsoHashMap::Map(map) => map.remove(key),
         }
@@ -272,11 +268,7 @@ impl<K: Eq + Hash, V> SsoHashMap<K, V> {
     pub fn remove_entry(&mut self, key: &K) -> Option<(K, V)> {
         match self {
             SsoHashMap::Array(array) => {
-                if let Some(index) = array.iter().position(|(k, _v)| k == key) {
-                    Some(array.swap_remove(index))
-                } else {
-                    None
-                }
+                array.iter().position(|(k, _v)| k == key).map(|index| array.swap_remove(index))
             }
             SsoHashMap::Map(map) => map.remove_entry(key),
         }
@@ -423,14 +415,14 @@ impl<K, V> IntoIterator for SsoHashMap<K, V> {
 
 /// adapts Item of array reference iterator to Item of hashmap reference iterator.
 #[inline(always)]
-fn adapt_array_ref_it<K, V>(pair: &'a (K, V)) -> (&'a K, &'a V) {
+fn adapt_array_ref_it<K, V>(pair: &(K, V)) -> (&K, &V) {
     let (a, b) = pair;
     (a, b)
 }
 
 /// adapts Item of array mut reference iterator to Item of hashmap mut reference iterator.
 #[inline(always)]
-fn adapt_array_mut_it<K, V>(pair: &'a mut (K, V)) -> (&'a K, &'a mut V) {
+fn adapt_array_mut_it<K, V>(pair: &mut (K, V)) -> (&K, &mut V) {
     let (a, b) = pair;
     (a, b)
 }