fix: clippy warnings, or_fun_call and unnecessary_lazy_evaluations (#846)

This commit is contained in:
Kim, JinSan
2023-01-13 19:10:02 +09:00
committed by GitHub
parent e6ca4c56c6
commit c4bafe809b
8 changed files with 28 additions and 38 deletions

View File

@ -7,9 +7,10 @@ use std::fmt::Display;
use thiserror::Error;
/// RLPx disconnect reason.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
pub enum DisconnectReason {
/// Disconnect requested by the local node or remote peer.
#[default]
DisconnectRequested = 0x00,
/// TCP related error
TcpSubsystemError = 0x01,
@ -65,12 +66,6 @@ impl Display for DisconnectReason {
}
}
impl Default for DisconnectReason {
fn default() -> Self {
DisconnectReason::DisconnectRequested
}
}
/// This represents an unknown disconnect reason with the given code.
#[derive(Debug, Clone, Error)]
#[error("unknown disconnect reason: {0}")]

View File

@ -715,11 +715,12 @@ impl TryFrom<u8> for P2PMessageID {
}
/// RLPx `p2p` protocol version
#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
pub enum ProtocolVersion {
/// `p2p` version 4
V4 = 4,
/// `p2p` version 5
#[default]
V5 = 5,
}
@ -744,12 +745,6 @@ impl Decodable for ProtocolVersion {
}
}
impl Default for ProtocolVersion {
fn default() -> Self {
ProtocolVersion::V5
}
}
#[cfg(test)]
mod tests {
use super::*;