Skip to content

Commit

Permalink
Other clippy things
Browse files Browse the repository at this point in the history
Signed-off-by: tison <[email protected]>
  • Loading branch information
tisonkun committed Mar 28, 2024
1 parent 70db33b commit 687f1cc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
1 change: 1 addition & 0 deletions src/raft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ impl<T: Storage> DerefMut for Raft<T> {
}
}

#[allow(dead_code)] // ensure Raft<T> is always Send
trait AssertSend: Send {}
impl<T: Storage + Send> AssertSend for Raft<T> {}

Expand Down
18 changes: 8 additions & 10 deletions src/raft_log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T: Storage> {
/// Contains all stable entries since the last snapshot.
Expand Down Expand Up @@ -58,12 +57,10 @@ pub struct RaftLog<T: Storage> {
pub applied: u64,
}

impl<T> ToString for RaftLog<T>
where
T: Storage,
{
fn to_string(&self) -> String {
format!(
impl<T: Storage> Display for RaftLog<T> {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(
f,
"committed={}, persisted={}, applied={}, unstable.offset={}, unstable.entries.len()={}",
self.committed,
self.persisted,
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 687f1cc

Please sign in to comment.