Jing Yang 3 лет назад
Родитель
Сommit
08de267389
2 измененных файлов с 5 добавлено и 5 удалено
  1. 4 4
      src/election.rs
  2. 1 1
      src/sync_log_entries.rs

+ 4 - 4
src/election.rs

@@ -353,7 +353,7 @@ impl<Command: ReplicableCommand> Raft<Command> {
         };
 
         RemoteContext::<Command>::term_marker().mark(reply.term);
-        return Some(reply.vote_granted && reply.term == term);
+        Some(reply.vote_granted && reply.term == term)
     }
 
     fn spawn_request_votes(
@@ -369,7 +369,7 @@ impl<Command: ReplicableCommand> Raft<Command> {
                 votes.push(one_vote);
             }
         }
-        return votes;
+        votes
     }
 
     async fn quorum_before_cancelled(
@@ -410,11 +410,11 @@ impl<Command: ReplicableCommand> Raft<Command> {
             }
         }
 
-        return if vote_count < quorum {
+        if vote_count < quorum {
             QuorumOrCancelled::Rejected
         } else {
             QuorumOrCancelled::Accepted(cancel_token)
-        };
+        }
     }
 
     fn become_leader(term: Term, this: ElectionCandidate<Command>) {

+ 1 - 1
src/sync_log_entries.rs

@@ -132,7 +132,7 @@ impl<Command: ReplicableCommand> Raft<Command> {
                     continue;
                 }
                 for peer in this.peers.iter() {
-                    let peer = peer.clone();
+                    let peer = *peer;
                     if peer != this.me && event.should_schedule(peer) {
                         let progress = &peer_progress[peer.0];
                         if let Event::NewTerm(_term, index) = event {