diff --git a/src/raft.rs b/src/raft.rs index 96f867bd..4e71d89c 100644 --- a/src/raft.rs +++ b/src/raft.rs @@ -284,6 +284,7 @@ impl DerefMut for Raft { } } +#[allow(dead_code)] // ensure Raft is always Send trait AssertSend: Send {} impl AssertSend for Raft {} diff --git a/src/raft_log.rs b/src/raft_log.rs index dfff305c..b82bb6de 100644 --- a/src/raft_log.rs +++ b/src/raft_log.rs @@ -15,20 +15,19 @@ // limitations under the License. use std::cmp; +use std::fmt::{Display, Formatter}; use slog::warn; use slog::Logger; +use slog::{debug, info, trace}; use crate::eraftpb::{Entry, Snapshot}; use crate::errors::{Error, Result, StorageError}; use crate::log_unstable::Unstable; use crate::storage::{GetEntriesContext, GetEntriesFor, Storage}; use crate::util; - pub use crate::util::NO_LIMIT; -use slog::{debug, info, trace}; - /// Raft log implementation pub struct RaftLog { /// Contains all stable entries since the last snapshot. @@ -58,12 +57,10 @@ pub struct RaftLog { pub applied: u64, } -impl ToString for RaftLog -where - T: Storage, -{ - fn to_string(&self) -> String { - format!( +impl Display for RaftLog { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + write!( + f, "committed={}, persisted={}, applied={}, unstable.offset={}, unstable.entries.len()={}", self.committed, self.persisted, @@ -702,13 +699,14 @@ mod test { panic::{self, AssertUnwindSafe}, }; + use protobuf::Message as PbMessage; + use crate::default_logger; use crate::eraftpb; use crate::errors::{Error, StorageError}; use crate::raft_log::{self, RaftLog}; use crate::storage::{GetEntriesContext, MemStorage}; use crate::NO_LIMIT; - use protobuf::Message as PbMessage; fn new_entry(index: u64, term: u64) -> eraftpb::Entry { let mut e = eraftpb::Entry::default();