From ce37de898267ec785c16179547262e48dc06d83d Mon Sep 17 00:00:00 2001 From: Bruce Mitchener Date: Mon, 1 Jul 2019 08:42:08 +0700 Subject: [PATCH] trace-fmt: use dyn attribute to make nightly happy (#127) --- tracing-fmt/src/default.rs | 2 +- tracing-fmt/src/lib.rs | 6 +++--- tracing-fmt/src/time.rs | 16 ++++++++-------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/tracing-fmt/src/default.rs b/tracing-fmt/src/default.rs index 0ae1cde5..0a7123ef 100644 --- a/tracing-fmt/src/default.rs +++ b/tracing-fmt/src/default.rs @@ -110,7 +110,7 @@ where fn format_event( &self, ctx: &span::Context, - writer: &mut fmt::Write, + writer: &mut dyn fmt::Write, event: &Event, ) -> fmt::Result { let meta = event.metadata(); diff --git a/tracing-fmt/src/lib.rs b/tracing-fmt/src/lib.rs index 42a0d172..3614b7b7 100644 --- a/tracing-fmt/src/lib.rs +++ b/tracing-fmt/src/lib.rs @@ -39,16 +39,16 @@ pub trait FormatEvent { fn format_event( &self, ctx: &span::Context, - writer: &mut fmt::Write, + writer: &mut dyn fmt::Write, event: &Event, ) -> fmt::Result; } -impl FormatEvent for fn(&span::Context, &mut fmt::Write, &Event) -> fmt::Result { +impl FormatEvent for fn(&span::Context, &mut dyn fmt::Write, &Event) -> fmt::Result { fn format_event( &self, ctx: &span::Context, - writer: &mut fmt::Write, + writer: &mut dyn fmt::Write, event: &Event, ) -> fmt::Result { (*self)(ctx, writer, event) diff --git a/tracing-fmt/src/time.rs b/tracing-fmt/src/time.rs index 0b3cfebf..cfbed651 100644 --- a/tracing-fmt/src/time.rs +++ b/tracing-fmt/src/time.rs @@ -21,26 +21,26 @@ pub trait FormatTime { /// When `format_time` is called, implementors should get the current time using their desired /// mechanism, and write it out to the given `fmt::Write`. Implementors must insert a trailing /// space themselves if they wish to separate the time from subsequent log message text. - fn format_time(&self, w: &mut fmt::Write) -> fmt::Result; + fn format_time(&self, w: &mut dyn fmt::Write) -> fmt::Result; } impl<'a, F> FormatTime for &'a F where F: FormatTime, { - fn format_time(&self, w: &mut fmt::Write) -> fmt::Result { + fn format_time(&self, w: &mut dyn fmt::Write) -> fmt::Result { (*self).format_time(w) } } impl FormatTime for () { - fn format_time(&self, _: &mut fmt::Write) -> fmt::Result { + fn format_time(&self, _: &mut dyn fmt::Write) -> fmt::Result { Ok(()) } } -impl FormatTime for fn(&mut fmt::Write) -> fmt::Result { - fn format_time(&self, w: &mut fmt::Write) -> fmt::Result { +impl FormatTime for fn(&mut dyn fmt::Write) -> fmt::Result { + fn format_time(&self, w: &mut dyn fmt::Write) -> fmt::Result { (*self)(w) } } @@ -76,7 +76,7 @@ impl From for Uptime { #[cfg(feature = "chrono")] impl FormatTime for SystemTime { - fn format_time(&self, w: &mut fmt::Write) -> fmt::Result { + fn format_time(&self, w: &mut dyn fmt::Write) -> fmt::Result { write!(w, "{} ", chrono::Local::now().format("%b %d %H:%M:%S%.3f")) } } @@ -88,7 +88,7 @@ impl FormatTime for SystemTime { } impl FormatTime for Uptime { - fn format_time(&self, w: &mut fmt::Write) -> fmt::Result { + fn format_time(&self, w: &mut dyn fmt::Write) -> fmt::Result { let e = self.epoch.elapsed(); write!(w, "{:4}.{:09}s ", e.as_secs(), e.subsec_nanos()) } @@ -96,7 +96,7 @@ impl FormatTime for Uptime { #[inline(always)] #[cfg(feature = "ansi")] -pub(crate) fn write(timer: T, writer: &mut fmt::Write) -> fmt::Result +pub(crate) fn write(timer: T, writer: &mut dyn fmt::Write) -> fmt::Result where T: FormatTime, {