From b5e9d0182a91a9c61885b51463cfe9ce629f6fa6 Mon Sep 17 00:00:00 2001 From: Lionel Faber Date: Mon, 21 Sep 2020 17:19:58 +0530 Subject: [PATCH] Implement Log for boxed data types that already implement the Log trait --- src/lib.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index cf6f09052..36a530799 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1167,6 +1167,23 @@ impl Log for NopLogger { fn flush(&self) {} } +#[cfg(feature = "std")] +impl Log for std::boxed::Box +where + T: ?Sized + Log, +{ + fn enabled(&self, metadata: &Metadata) -> bool { + self.as_ref().enabled(metadata) + } + + fn log(&self, record: &Record) { + self.as_ref().log(record) + } + fn flush(&self) { + self.as_ref().flush() + } +} + /// Sets the global maximum log level. /// /// Generally, this should only be called by the active logging implementation.