From 43e34becf47c6f1fe5808c0d9a19634676af2371 Mon Sep 17 00:00:00 2001 From: Lucas Timmins Date: Wed, 3 Oct 2018 20:13:21 +0800 Subject: [PATCH 1/3] Remove redundant 'static from &str --- rust/src/lock.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/src/lock.rs b/rust/src/lock.rs index 0cdae30..85dee74 100644 --- a/rust/src/lock.rs +++ b/rust/src/lock.rs @@ -16,7 +16,7 @@ use std::time::{Duration}; use requests::{get, put, Error, StatusCode}; -pub const DEFAULT_BASE_URI: &'static str = "http://localhost:8080"; +pub const DEFAULT_BASE_URI: &str = "http://localhost:8080"; From 0fe74eb3ead13a63a991870cf6b918d05308de3d Mon Sep 17 00:00:00 2001 From: Lucas Timmins Date: Wed, 3 Oct 2018 20:15:53 +0800 Subject: [PATCH 2/3] Convert loop that iterates once to if statement --- rust/src/election.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/rust/src/election.rs b/rust/src/election.rs index 6d274ca..e1a94a8 100644 --- a/rust/src/election.rs +++ b/rust/src/election.rs @@ -156,11 +156,10 @@ impl<'a> Election<'a> { let leader_fn = self.leader_fn.clone(); let follower_fn = self.follower_fn.clone(); self.running.store(true, Ordering::Relaxed); - while self.is_running() { + if self.is_running() { self.lock.lock(|| leader_fn()); follower_fn(); - break; } } From 953a56740857e5796185cddd8a0b9d29a5ab8c1e Mon Sep 17 00:00:00 2001 From: Lucas Timmins Date: Wed, 3 Oct 2018 20:17:12 +0800 Subject: [PATCH 3/3] Derive copy for `Handler` to avoid pass by ref lints --- rust/src/election.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/rust/src/election.rs b/rust/src/election.rs index e1a94a8..28d1ac5 100644 --- a/rust/src/election.rs +++ b/rust/src/election.rs @@ -131,6 +131,7 @@ pub struct Election<'a> { follower_fn: Arc () + Send + Sync + 'a>>, } +#[derive(Copy, Clone)] pub enum Handler { Leader, Follower,