Skip to content

Commit

Permalink
Fix clippy(nightly) warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
sile committed Feb 11, 2023
1 parent 43d41b3 commit edcb74a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 50 deletions.
9 changes: 2 additions & 7 deletions src/syslog/facility.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use std::str::FromStr;
/// `enum` are available on all platforms, and variants not present on the
/// target platform will be mapped to a reasonable alternative.
#[allow(missing_docs)]
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
#[derive(Default, Clone, Copy, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
#[non_exhaustive]
#[serde(rename_all = "lowercase")]
pub enum Facility {
Expand Down Expand Up @@ -110,6 +110,7 @@ pub enum Facility {
Security,

Syslog,
#[default]
User,
Uucp,
}
Expand Down Expand Up @@ -152,12 +153,6 @@ impl Facility {
}
}

impl Default for Facility {
fn default() -> Self {
Facility::User
}
}

impl Display for Facility {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str(self.name())
Expand Down
9 changes: 2 additions & 7 deletions src/syslog/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,23 +350,18 @@ fn test_default_msg_format() {
}

/// Enumeration of built-in `MsgFormat`s, for use with serde.
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[derive(Default, Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
#[non_exhaustive]
#[serde(rename_all = "snake_case")]
pub enum MsgFormatConfig {
/// [`DefaultMsgFormat`](struct.DefaultMsgFormat.html).
#[default]
Default,

/// [`BasicMsgFormat`](struct.BasicMsgFormat.html).
Basic,
}

impl Default for MsgFormatConfig {
fn default() -> Self {
MsgFormatConfig::Default
}
}

impl From<MsgFormatConfig> for Arc<dyn MsgFormat> {
fn from(conf: MsgFormatConfig) -> Self {
Self::from(&conf)
Expand Down
8 changes: 2 additions & 6 deletions src/terminal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,20 +132,16 @@ impl Build for TerminalLoggerBuilder {
///
/// assert_eq!(Destination::default(), Destination::Stderr);
/// ```
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[derive(Default, Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum Destination {
/// Standard output.
Stdout,

/// Standard error.
#[default]
Stderr,
}
impl Default for Destination {
fn default() -> Self {
Destination::Stderr
}
}
impl Destination {
fn to_decorator(self) -> Decorator {
let maybe_term_decorator = match self {
Expand Down
42 changes: 12 additions & 30 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,14 @@ use std::str::FromStr;
///
/// See [slog's documentation](https://docs.rs/slog/2.2.3/slog/#notable-details) for more details.
#[allow(missing_docs)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
#[derive(
Default, Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize,
)]
#[serde(rename_all = "lowercase")]
pub enum Severity {
Trace,
Debug,
#[default]
Info,
Warning,
Error,
Expand All @@ -56,11 +59,6 @@ impl Severity {
LevelFilter::new(drain, self.as_level())
}
}
impl Default for Severity {
fn default() -> Self {
Severity::Info
}
}
impl FromStr for Severity {
type Err = Error;
fn from_str(s: &str) -> Result<Self, Error> {
Expand Down Expand Up @@ -159,11 +157,12 @@ impl KVFilterParameters {
///
/// assert_eq!(Format::default(), Format::Full);
/// ```
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[derive(Default, Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
#[non_exhaustive]
pub enum Format {
/// Full format.
#[default]
Full,

/// Compact format.
Expand All @@ -173,11 +172,6 @@ pub enum Format {
#[cfg(feature = "json")]
Json,
}
impl Default for Format {
fn default() -> Self {
Format::Full
}
}
impl FromStr for Format {
type Err = Error;
fn from_str(s: &str) -> Result<Self, Error> {
Expand All @@ -203,17 +197,13 @@ impl FromStr for Format {
/// assert_eq!(TimeZone::default(), TimeZone::Local);
/// ```
#[allow(missing_docs)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[derive(Default, Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum TimeZone {
Utc,
#[default]
Local,
}
impl Default for TimeZone {
fn default() -> Self {
TimeZone::Local
}
}
impl FromStr for TimeZone {
type Err = Error;
fn from_str(s: &str) -> Result<Self, Error> {
Expand All @@ -237,20 +227,16 @@ impl FromStr for TimeZone {
/// assert_eq!(SourceLocation::default(), SourceLocation::ModuleAndLine);
/// ```
#[allow(missing_docs)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[derive(Default, Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
#[non_exhaustive]
pub enum SourceLocation {
None,
#[default]
ModuleAndLine,
FileAndLine,
LocalFileAndLine,
}
impl Default for SourceLocation {
fn default() -> Self {
SourceLocation::ModuleAndLine
}
}
impl FromStr for SourceLocation {
type Err = Error;
fn from_str(s: &str) -> Result<Self, Error> {
Expand Down Expand Up @@ -280,19 +266,15 @@ impl FromStr for SourceLocation {
/// assert_eq!(OverflowStrategy::default(), OverflowStrategy::DropAndReport);
/// ```
#[allow(missing_docs)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[derive(Default, Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
#[non_exhaustive]
pub enum OverflowStrategy {
#[default]
DropAndReport,
Drop,
Block,
}
impl Default for OverflowStrategy {
fn default() -> Self {
OverflowStrategy::DropAndReport
}
}
impl FromStr for OverflowStrategy {
type Err = Error;
fn from_str(s: &str) -> Result<Self, Error> {
Expand Down

0 comments on commit edcb74a

Please sign in to comment.