From c2829f3ebb7d71bedd42993053874979bdaf7b62 Mon Sep 17 00:00:00 2001 From: David Barsky Date: Sat, 5 Sep 2020 13:15:05 -0400 Subject: [PATCH 1/2] core: add missing Option -> LevelFilter conversion --- tracing-core/src/metadata.rs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/tracing-core/src/metadata.rs b/tracing-core/src/metadata.rs index c5c67912f2..d06ea88e17 100644 --- a/tracing-core/src/metadata.rs +++ b/tracing-core/src/metadata.rs @@ -365,10 +365,13 @@ impl From for LevelFilter { } } -impl Into> for LevelFilter { +impl From> for LevelFilter { #[inline] - fn into(self) -> Option { - self.into_level() + fn from(level: Option) -> Self { + match level { + Some(level) => LevelFilter::from_level(level), + None => LevelFilter::OFF, + } } } @@ -819,8 +822,15 @@ mod tests { ]; for (filter, level) in mapping.iter() { assert_eq!(filter.clone().into_level(), *level); - if let Some(level) = level { - assert_eq!(LevelFilter::from_level(level.clone()), *filter); + match level { + Some(level) => { + let actual: LevelFilter = level.clone().into(); + assert_eq!(actual, *filter); + } + None => { + let actual: LevelFilter = None.into(); + assert_eq!(actual, *filter); + } } } } From d6783d32fad4fd2c752fdf5f77a9a107ae5af38c Mon Sep 17 00:00:00 2001 From: David Barsky Date: Sat, 5 Sep 2020 14:04:31 -0400 Subject: [PATCH 2/2] address comments --- tracing-core/src/metadata.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tracing-core/src/metadata.rs b/tracing-core/src/metadata.rs index d06ea88e17..c575a55b45 100644 --- a/tracing-core/src/metadata.rs +++ b/tracing-core/src/metadata.rs @@ -368,10 +368,14 @@ impl From for LevelFilter { impl From> for LevelFilter { #[inline] fn from(level: Option) -> Self { - match level { - Some(level) => LevelFilter::from_level(level), - None => LevelFilter::OFF, - } + Self(level) + } +} + +impl Into> for LevelFilter { + #[inline] + fn into(self) -> Option { + self.into_level() } }