From 68bc91f28f2f23fa5a90cade2fffd4cf08b90e43 Mon Sep 17 00:00:00 2001 From: Jack Wrenn Date: Thu, 16 Jun 2022 16:27:35 -0400 Subject: [PATCH] core: `impl Collect` for `Box`, `Arc` (#2161) These broader impls supersede the previous impls where the inner type was a `dyn Collect`. With these generic impls, you no longer must (but still can, if you wish) cast the inner type of a boxed or arc'd collector to `dyn Collect` to use it as a `Collect`. --- tracing-core/src/collect.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tracing-core/src/collect.rs b/tracing-core/src/collect.rs index a939ef1be2..4bafc00d92 100644 --- a/tracing-core/src/collect.rs +++ b/tracing-core/src/collect.rs @@ -654,7 +654,10 @@ impl Collect for NoCollector { } #[cfg(feature = "alloc")] -impl Collect for alloc::boxed::Box { +impl Collect for alloc::boxed::Box +where + C: Collect + ?Sized, +{ #[inline] fn register_callsite(&self, metadata: &'static Metadata<'static>) -> Interest { self.as_ref().register_callsite(metadata) @@ -725,7 +728,10 @@ impl Collect for alloc::boxed::Box { } #[cfg(feature = "alloc")] -impl Collect for alloc::sync::Arc { +impl Collect for alloc::sync::Arc +where + C: Collect + ?Sized, +{ #[inline] fn register_callsite(&self, metadata: &'static Metadata<'static>) -> Interest { self.as_ref().register_callsite(metadata)