Skip to content

Commit

Permalink
Derive Default on enums (#565)
Browse files Browse the repository at this point in the history
  • Loading branch information
Swatinem committed Apr 6, 2023
1 parent 8e042b4 commit c7f5965
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions sentry-types/src/protocol/v7.rs
Original file line number Diff line number Diff line change
Expand Up @@ -648,11 +648,12 @@ pub struct Exception {
pub struct ParseLevelError;

/// Represents the level of severity of an event or breadcrumb.
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
pub enum Level {
/// Indicates very spammy debug information.
Debug,
/// Informational messages.
#[default]
Info,
/// A warning.
Warning,
Expand All @@ -662,12 +663,6 @@ pub enum Level {
Fatal,
}

impl Default for Level {
fn default() -> Level {
Level::Info
}
}

impl str::FromStr for Level {
type Err = ParseLevelError;

Expand Down Expand Up @@ -785,9 +780,10 @@ impl Default for Breadcrumb {
}

/// An IP address, either IPv4, IPv6 or Auto.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Ord, PartialOrd, Hash)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Ord, PartialOrd, Hash, Default)]
pub enum IpAddress {
/// The IP address needs to be infered from the user's context.
#[default]
Auto,
/// The exact given IP address (v4 or v6).
Exact(IpAddr),
Expand All @@ -811,12 +807,6 @@ impl cmp::PartialOrd<IpAddr> for IpAddress {
}
}

impl Default for IpAddress {
fn default() -> IpAddress {
IpAddress::Auto
}
}

impl fmt::Display for IpAddress {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
Expand Down

0 comments on commit c7f5965

Please sign in to comment.