Skip to content

Commit a6cb13e

Browse files
jswrennhawkw
authored andcommitted
core: impl<S: Subscriber + ?Sized> Subscriber for Box<S>, Arc<S> (#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`.
1 parent f90b455 commit a6cb13e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

tracing-core/src/subscriber.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,10 @@ impl Subscriber for NoSubscriber {
662662
fn exit(&self, _span: &span::Id) {}
663663
}
664664

665-
impl Subscriber for Box<dyn Subscriber + Send + Sync + 'static> {
665+
impl<S> Subscriber for Box<S>
666+
where
667+
S: Subscriber + ?Sized,
668+
{
666669
#[inline]
667670
fn register_callsite(&self, metadata: &'static Metadata<'static>) -> Interest {
668671
self.as_ref().register_callsite(metadata)
@@ -739,7 +742,10 @@ impl Subscriber for Box<dyn Subscriber + Send + Sync + 'static> {
739742
}
740743
}
741744

742-
impl Subscriber for Arc<dyn Subscriber + Send + Sync + 'static> {
745+
impl<S> Subscriber for Arc<S>
746+
where
747+
S: Subscriber + ?Sized,
748+
{
743749
#[inline]
744750
fn register_callsite(&self, metadata: &'static Metadata<'static>) -> Interest {
745751
self.as_ref().register_callsite(metadata)

0 commit comments

Comments
 (0)