Browse Source

tweaks measure! to handle measure!(self.influx, ...)

master
Jonathan Strong 7 years ago
parent
commit
a7a3f68e92
1 changed files with 18 additions and 1 deletions
  1. +18
    -1
      src/influx.rs

+ 18
- 1
src/influx.rs View File

@@ -159,7 +159,7 @@ macro_rules! measure {
meas meas
}}; }};


($m:tt, $name:tt, $( $t:tt ( $($tail:tt)* ) ),+ $(,)*) => {
($m:expr, $name:tt, $( $t:tt ( $($tail:tt)* ) ),+ $(,)*) => {
measure!($m, $name, $($t [ $($tail)* ] ),+) measure!($m, $name, $($t [ $($tail)* ] ),+)
}; };


@@ -656,6 +656,23 @@ mod tests {
assert_eq!(m.timestamp, Some(1)); 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] #[bench]
fn influx_writer_send_basic(b: &mut Bencher) { fn influx_writer_send_basic(b: &mut Bencher) {
let m = InfluxWriter::default(); let m = InfluxWriter::default();


Loading…
Cancel
Save