From b38b9e101a8bb60fb8c6b257b091c8d23d1b2017 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Wed, 14 Oct 2015 14:16:48 +0200 Subject: [PATCH 1/2] Use if-let rather than map() in parse_logging_spec. --- src/liblog/directive.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/liblog/directive.rs b/src/liblog/directive.rs index 12a5c1311705d..3958969cfca32 100644 --- a/src/liblog/directive.rs +++ b/src/liblog/directive.rs @@ -46,7 +46,7 @@ pub fn parse_logging_spec(spec: &str) -> (Vec, Option) { spec); return (dirs, None); } - mods.map(|m| { + if let Some(m) = mods { for s in m.split(',') { if s.is_empty() { continue @@ -83,7 +83,7 @@ pub fn parse_logging_spec(spec: &str) -> (Vec, Option) { level: log_level, }); } - }); + } (dirs, filter.map(str::to_owned)) } From 695c9586fe5a10b0d1d14ec3c4e5a5364b8ab3ea Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Wed, 14 Oct 2015 14:17:06 +0200 Subject: [PATCH 2/2] Remove the unnecessary local variable in set_logger. --- src/liblog/lib.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/liblog/lib.rs b/src/liblog/lib.rs index b3268c32f18f7..9cb835bd8525d 100644 --- a/src/liblog/lib.rs +++ b/src/liblog/lib.rs @@ -328,8 +328,7 @@ pub fn log_level() -> u32 { /// Replaces the thread-local logger with the specified logger, returning the old /// logger. pub fn set_logger(logger: Box) -> Option> { - let mut l = Some(logger); - LOCAL_LOGGER.with(|slot| mem::replace(&mut *slot.borrow_mut(), l.take())) + LOCAL_LOGGER.with(|slot| mem::replace(&mut *slot.borrow_mut(), Some(logger))) } /// A LogRecord is created by the logging macros, and passed as the only