From a7a3f68e92bd35351bd4159666165195555c703f Mon Sep 17 00:00:00 2001 From: Jonathan Strong Date: Tue, 19 Dec 2017 01:16:36 -0500 Subject: [PATCH] tweaks measure! to handle measure!(self.influx, ...) --- src/influx.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/influx.rs b/src/influx.rs index ab5ad3f..f095bfb 100644 --- a/src/influx.rs +++ b/src/influx.rs @@ -159,7 +159,7 @@ macro_rules! measure { meas }}; - ($m:tt, $name:tt, $( $t:tt ( $($tail:tt)* ) ),+ $(,)*) => { + ($m:expr, $name:tt, $( $t:tt ( $($tail:tt)* ) ),+ $(,)*) => { measure!($m, $name, $($t [ $($tail)* ] ),+) }; @@ -656,6 +656,23 @@ mod tests { assert_eq!(m.timestamp, Some(1)); } + #[test] + fn it_uses_measure_macro_on_a_self_attribute() { + struct A { + pub influx: InfluxWriter, + } + + impl A { + fn f(&self) { + measure!(self.influx, test, t(color, "red"), i(n, 1)); + } + } + + let a = A { influx: InfluxWriter::default() }; + + a.f(); + } + #[bench] fn influx_writer_send_basic(b: &mut Bencher) { let m = InfluxWriter::default();