From 5830d1d13ca51b6b1c96bd12c79eee649efec3a6 Mon Sep 17 00:00:00 2001 From: Jonathan Strong Date: Tue, 18 Aug 2020 16:45:14 -0400 Subject: [PATCH] in measure, allow `Option` fields with "D" prefix example: ``` let a: Option = Some(d128::from_str("123.456").unwrap()); let b: Option = None; measure!(influx, meas, D(a), D(b)); ``` in the `None` case, no field is added at all. --- Cargo.toml | 2 +- src/lib.rs | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 4c632d8..68fc759 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "influx-writer" -version = "0.10.0" +version = "0.10.1" authors = ["Jonathan Strong "] edition = "2018" diff --git a/src/lib.rs b/src/lib.rs index 9282403..4110637 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -140,6 +140,13 @@ macro_rules! measure { (@ea u, $meas:ident, $k:expr, $v:expr) => { $meas = $meas.add_field($k, $crate::OwnedValue::Uuid($v)) }; (@ea b, $meas:ident, $k:expr, $v:expr) => { $meas = $meas.add_field($k, $crate::OwnedValue::Boolean(bool::from($v))) }; + (@ea D, $meas:ident, $k:expr, $v:expr) => { + match $v { + Some(v) => { $meas = $meas.add_field($k, $crate::OwnedValue::D128(v)) } + None => {} + } + }; + (@as_expr $e:expr) => {$e}; (@count_tags) => {0usize};