From 7acf28698028a33c53ddbeff875d6f3f99e92f57 Mon Sep 17 00:00:00 2001 From: Jack Wrenn Date: Thu, 16 Jun 2022 16:27:35 -0400 Subject: [PATCH] core: `impl Subscriber` for `Box`, `Arc` (#2161) These broader impls supersede the previous impls where the inner type was a `dyn Subscriber`. With these generic impls, you no longer must (but still can, if you wish) cast the inner type of a boxed or arc'd subscriber to `dyn Subscriber` to use it as a `Subscriber`. --- tracing-core/src/subscriber.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tracing-core/src/subscriber.rs b/tracing-core/src/subscriber.rs index 3d6aaa3441..9c7e210b06 100644 --- a/tracing-core/src/subscriber.rs +++ b/tracing-core/src/subscriber.rs @@ -662,7 +662,10 @@ impl Subscriber for NoSubscriber { fn exit(&self, _span: &span::Id) {} } -impl Subscriber for Box { +impl Subscriber for Box +where + S: Subscriber + ?Sized, +{ #[inline] fn register_callsite(&self, metadata: &'static Metadata<'static>) -> Interest { self.as_ref().register_callsite(metadata) @@ -739,7 +742,10 @@ impl Subscriber for Box { } } -impl Subscriber for Arc { +impl Subscriber for Arc +where + S: Subscriber + ?Sized, +{ #[inline] fn register_callsite(&self, metadata: &'static Metadata<'static>) -> Interest { self.as_ref().register_callsite(metadata)