mirror of
https://github.com/tokio-rs/tracing.git
synced 2026-03-23 08:04:32 +00:00
core: impl<C: Collect + ?Sized> Collect for Box<C>, Arc<C> (#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`.
This commit is contained in:
@@ -654,7 +654,10 @@ impl Collect for NoCollector {
|
||||
}
|
||||
|
||||
#[cfg(feature = "alloc")]
|
||||
impl Collect for alloc::boxed::Box<dyn Collect + Send + Sync + 'static> {
|
||||
impl<C> Collect for alloc::boxed::Box<C>
|
||||
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<dyn Collect + Send + Sync + 'static> {
|
||||
}
|
||||
|
||||
#[cfg(feature = "alloc")]
|
||||
impl Collect for alloc::sync::Arc<dyn Collect + Send + Sync + 'static> {
|
||||
impl<C> Collect for alloc::sync::Arc<C>
|
||||
where
|
||||
C: Collect + ?Sized,
|
||||
{
|
||||
#[inline]
|
||||
fn register_callsite(&self, metadata: &'static Metadata<'static>) -> Interest {
|
||||
self.as_ref().register_callsite(metadata)
|
||||
|
||||
Reference in New Issue
Block a user