From 6fbef0a52888b07b8a3499b5c48b0f02313e6e79 Mon Sep 17 00:00:00 2001 From: Eliza Weisman Date: Thu, 7 Mar 2019 11:54:21 -0800 Subject: [PATCH] trace-core: Add `'static` bound to `Subscriber` (#953) --- tokio-trace/tests/support/subscriber.rs | 12 +++++++++--- tokio-trace/tokio-trace-core/src/subscriber.rs | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/tokio-trace/tests/support/subscriber.rs b/tokio-trace/tests/support/subscriber.rs index b4fe5178d..7266335cc 100644 --- a/tokio-trace/tests/support/subscriber.rs +++ b/tokio-trace/tests/support/subscriber.rs @@ -57,7 +57,10 @@ pub fn mock() -> MockSubscriber bool> { } } -impl bool> MockSubscriber { +impl MockSubscriber +where + F: Fn(&Metadata) -> bool + 'static, +{ pub fn enter(mut self, span: MockSpan) -> Self { self.expected.push_back(Expect::Enter(span)); self @@ -106,7 +109,7 @@ impl bool> MockSubscriber { pub fn with_filter(self, filter: G) -> MockSubscriber where - G: Fn(&Metadata) -> bool, + G: Fn(&Metadata) -> bool + 'static, { MockSubscriber { filter, @@ -133,7 +136,10 @@ impl bool> MockSubscriber { } } -impl bool> Subscriber for Running { +impl Subscriber for Running +where + F: Fn(&Metadata) -> bool + 'static, +{ fn enabled(&self, meta: &Metadata) -> bool { (self.filter)(meta) } diff --git a/tokio-trace/tokio-trace-core/src/subscriber.rs b/tokio-trace/tokio-trace-core/src/subscriber.rs index 956eca176..f1e3cac72 100644 --- a/tokio-trace/tokio-trace-core/src/subscriber.rs +++ b/tokio-trace/tokio-trace-core/src/subscriber.rs @@ -33,7 +33,7 @@ use {field, span, Event, Metadata}; /// /// [ID]: ::span::Span /// [`new_span`]: ::Span::new_span -pub trait Subscriber { +pub trait Subscriber: 'static { // === Span registry methods ============================================== /// Registers a new callsite with this subscriber, returning whether or not