Procházet zdrojové kódy

Address clippy suggestions.

Jing Yang před 2 roky
rodič
revize
58369ffd9f

+ 1 - 1
raft/src/storage/decode_and_encode.rs

@@ -12,7 +12,7 @@ pub(crate) fn encode_log_entry<Command: Serialize>(
 pub(crate) fn decode_log_entry<'a, Command: Deserialize<'a>>(
     stored: &'a [u8],
 ) -> LogEntry<Command> {
-    bincode::deserialize(&stored).expect("Deserialization should never fail")
+    bincode::deserialize(stored).expect("Deserialization should never fail")
 }
 
 pub(crate) fn encode_voted_for(voted_for: &Option<Peer>) -> String {

+ 1 - 1
raft/src/storage/mod.rs

@@ -101,7 +101,7 @@ pub trait RaftStorageTrait {
     /// Whether or not this storage system requires log compaction. Any
     /// non-experimental storage must require log compaction.
     fn log_compaction_required(&self) -> bool {
-        return true;
+        true
     }
 
     /// Returns a monitor that helps Raft decide when a compaction should happen

+ 1 - 1
raft/src/utils/do_nothing.rs

@@ -77,7 +77,7 @@ pub struct DoNothingRaftStorageMonitor;
 
 impl RaftStorageMonitorTrait for DoNothingRaftStorageMonitor {
     fn should_compact_log_now(&self) -> bool {
-        return false;
+        false
     }
 }
 

+ 1 - 0
raft/src/verify_authority.rs

@@ -480,6 +480,7 @@ mod tests {
         {
             let state = daemon.state.lock();
             assert_eq!(1, state.queue.len());
+            #[allow(clippy::get_first)]
             let token = state.queue.get(0).unwrap();
             assert_eq!(
                 [Beat(11), Beat(9), Beat(7), Beat(5), Beat(3)],

+ 2 - 2
test_configs/src/in_memory_storage.rs

@@ -127,7 +127,7 @@ impl RaftStorageMonitorTrait for InMemoryStorageMonitor {
     fn should_compact_log_now(&self) -> bool {
         let stored = self.stored.0.lock();
         let total_size = stored.total_size();
-        return total_size > self.max_state_bytes;
+        total_size > self.max_state_bytes
     }
 }
 
@@ -242,7 +242,7 @@ mod tests {
             Self {
                 index,
                 amount: index as f64 * 7.0,
-                description: char::from('a' as u8 + index as u8).to_string(),
+                description: char::from(b'a' + index as u8).to_string(),
             }
         }
     }