Просмотр исходного кода

Fix two clippy errors.

1. item order in LogEntry.
2. Implement From<> instead of Into<>.
Jing Yang 4 лет назад
Родитель
Сommit
6706ad3389
2 измененных файлов с 4 добавлено и 4 удалено
  1. 1 1
      src/lib.rs
  2. 3 3
      src/persister.rs

+ 1 - 1
src/lib.rs

@@ -49,8 +49,8 @@ pub type Index = usize;
 
 #[derive(Clone, Debug, Serialize, Deserialize)]
 struct LogEntry<Command> {
-    term: Term,
     index: Index,
+    term: Term,
     command: Command,
 }
 

+ 3 - 3
src/persister.rs

@@ -48,9 +48,9 @@ impl<Command: DeserializeOwned> TryFrom<Bytes> for PersistedRaftState<Command> {
     }
 }
 
-impl<Command: Serialize> Into<Bytes> for PersistedRaftState<Command> {
-    fn into(self) -> Bytes {
-        bincode::serialize(&self)
+impl<Command: Serialize> From<PersistedRaftState<Command>> for Bytes {
+    fn from(value: PersistedRaftState<Command>) -> Bytes {
+        bincode::serialize(&value)
             .expect("Serialization should not fail")
             .into()
     }