From 3764f75881cf60c00967b6078471b58201fa41e8 Mon Sep 17 00:00:00 2001
From: Yaroslav Dynnikov <yaroslav.dynnikov@gmail.com>
Date: Thu, 30 Jun 2022 00:31:13 +0300
Subject: [PATCH] chore: replace another "if" with another "match"

---
 src/traft/node.rs | 50 +++++++++++++++++++++++------------------------
 1 file changed, 25 insertions(+), 25 deletions(-)

diff --git a/src/traft/node.rs b/src/traft/node.rs
index f5c0f39da5..3210ee0280 100644
--- a/src/traft/node.rs
+++ b/src/traft/node.rs
@@ -406,33 +406,33 @@ fn handle_committed_conf_change(
     // (`V2` or not `V2`) makes a significant
     // difference in `entry.data` binary layout
     // and in joint state transitions.
-    let conf_state;
-
-    if entry.entry_type == raft::EntryType::EntryConfChange {
-        let mut cc = raft::ConfChange::default();
-        cc.merge_from_bytes(&entry.data).unwrap();
-
-        *config_changed = true;
-        conf_state = raw_node.apply_conf_change(&cc).unwrap();
-    } else if entry.entry_type == raft::EntryType::EntryConfChangeV2 {
-        let mut cc = raft::ConfChangeV2::default();
-        cc.merge_from_bytes(&entry.data).unwrap();
-
-        // Unlock the latch only when leaving the joint state
-        if cc.changes.is_empty() {
-            if let Some(latch) = joint_state_latch {
-                latch.notify.notify_ok(entry.index);
-                *joint_state_latch = None;
-                *config_changed = true;
-            }
+    let conf_state = match entry.entry_type {
+        raft::EntryType::EntryConfChange => {
+            let mut cc = raft::ConfChange::default();
+            cc.merge_from_bytes(&entry.data).unwrap();
+
+            *config_changed = true;
+            raw_node.apply_conf_change(&cc).unwrap()
         }
+        raft::EntryType::EntryConfChangeV2 => {
+            let mut cc = raft::ConfChangeV2::default();
+            cc.merge_from_bytes(&entry.data).unwrap();
+
+            // Unlock the latch only when leaving the joint state
+            if cc.changes.is_empty() {
+                if let Some(latch) = joint_state_latch {
+                    latch.notify.notify_ok(entry.index);
+                    *joint_state_latch = None;
+                    *config_changed = true;
+                }
+            }
 
-        // ConfChangeTransition::Implicit implies that at this
-        // moment raft-rs will implicitly propose another empty
-        // conf change that represents leaving the joint state.
-        conf_state = raw_node.apply_conf_change(&cc).unwrap()
-    } else {
-        unreachable!();
+            // ConfChangeTransition::Implicit implies that at this
+            // moment raft-rs will implicitly propose another empty
+            // conf change that represents leaving the joint state.
+            raw_node.apply_conf_change(&cc).unwrap()
+        }
+        _ => unreachable!(),
     };
 
     Storage::persist_conf_state(&conf_state).unwrap();
-- 
GitLab