From 681fcc015fbd9184b4966ec58efb3cb922fa1af5 Mon Sep 17 00:00:00 2001 From: Luca Pizzamiglio Date: Wed, 10 Apr 2019 15:41:19 +0200 Subject: [PATCH] Fix clippy warnings --- src/ip.rs | 6 +++--- src/logopt.rs | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ip.rs b/src/ip.rs index 5f76b50..8b97724 100644 --- a/src/ip.rs +++ b/src/ip.rs @@ -38,7 +38,7 @@ pub struct HostV4Opt { impl GetWithDefault for HostV4Opt { type Item = Ipv4Addr; fn get_with_default>(&self, default: T) -> Self::Item { - self.host_addr.unwrap_or(default.into()) + self.host_addr.unwrap_or_else(|| default.into()) } } @@ -111,7 +111,7 @@ pub struct HostV6Opt { impl GetWithDefault for HostV6Opt { type Item = Ipv6Addr; fn get_with_default>(&self, default: T) -> Self::Item { - self.host_addr.unwrap_or(default.into()) + self.host_addr.unwrap_or_else(|| default.into()) } } @@ -184,7 +184,7 @@ pub struct HostOpt { impl GetWithDefault for HostOpt { type Item = IpAddr; fn get_with_default>(&self, default: T) -> Self::Item { - self.host_addr.unwrap_or(default.into()) + self.host_addr.unwrap_or_else(|| default.into()) } } diff --git a/src/logopt.rs b/src/logopt.rs index 441da73..ff68bba 100644 --- a/src/logopt.rs +++ b/src/logopt.rs @@ -171,7 +171,7 @@ pub struct LogLevelNoDef { impl GetWithDefault for LogLevelNoDef { type Item = LevelFilter; fn get_with_default>(&self, default: T) -> Self::Item { - self.log_level.unwrap_or(default.into()) + self.log_level.unwrap_or_else(|| default.into()) } } @@ -234,7 +234,7 @@ pub struct LogLevelNoDefLower { impl GetWithDefault for LogLevelNoDefLower { type Item = LevelFilter; fn get_with_default>(&self, default: T) -> Self::Item { - self.log_level.unwrap_or(default.into()) + self.log_level.unwrap_or_else(|| default.into()) } }