]> git.lizzy.rs Git - rust.git/commitdiff
removed unwrap
authorJeroen Vannevel <jer_vannevel@outlook.com>
Tue, 11 Jan 2022 21:44:30 +0000 (21:44 +0000)
committerJeroen Vannevel <jer_vannevel@outlook.com>
Fri, 14 Jan 2022 01:32:11 +0000 (01:32 +0000)
crates/ide_assists/src/handlers/merge_match_arms.rs

index 69d1bc0adcf500da54733f96c083c678efa4a969..f5366bee1216fae5f9764881e55de50d9905729a 100644 (file)
@@ -101,19 +101,18 @@ fn are_same_types(
 ) -> bool {
     let arm_types = get_arm_types(&ctx, &arm);
     for other_arm_type_entry in arm_types {
-        let current_arm_type = current_arm_types.get_key_value(&other_arm_type_entry.0);
-        if current_arm_type.is_none() {
-            return false;
-        }
-
-        let unwrapped_current_arm_type = current_arm_type.unwrap().1;
-
-        if let (Some(other_arm_type), Some(current_arm_type)) =
-            (other_arm_type_entry.1, unwrapped_current_arm_type)
-        {
-            if other_arm_type.original != current_arm_type.original {
-                return false;
+        let current_arm_type_kv = current_arm_types.get_key_value(&other_arm_type_entry.0);
+        if let Some(current_arm_type) = current_arm_type_kv {
+            if let (Some(other_arm_type), Some(current_arm_type)) =
+                (other_arm_type_entry.1, current_arm_type.1)
+            {
+                if other_arm_type.original != current_arm_type.original {
+                    return false;
+                }
             }
+        } else {
+            // No corresponding field found
+            return false;
         }
     }