diff --git a/Cargo.toml b/Cargo.toml index eac86a0..c28f732 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "influx-writer" -version = "0.19.0" +version = "0.19.1" authors = ["Jonathan Strong "] edition = "2018" description = "opinionated influxdb client" diff --git a/src/lib.rs b/src/lib.rs index c7f9aa7..fa7a212 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -158,15 +158,13 @@ macro_rules! measure { } }; (@ea I, $meas:ident, $k:expr, $v:expr) => { - match $v { - Some(v) => { $meas = $meas.add_field($k, $crate::OwnedValue::Integer(v)) } - None => {} + if $v.is_some() { + $meas = $meas.add_field($k, $crate::OwnedValue::Integer(AsI64::as_i64($v.unwrap()))); } }; - (@ea F, $meas:ident, $k:expr, $v:expr) => { - match $v { - Some(v) => { $meas = $meas.add_field($k, $crate::OwnedValue::Float(v)) } - None => {} + (@ea F, $meas:ident, $k:expr, $v:expr) => { + if $v.is_some() { + $meas = $meas.add_field($k, $crate::OwnedValue::Float(AsF64::as_f64($v.unwrap()))); } }; // (@ea T, $meas:ident, $k:expr, $v:expr) => { @@ -1225,11 +1223,13 @@ mod tests { #[test] fn check_uppercase_shorthands_on_optional_field_and_tag_values() { + let e: Option = None; + let h: Option = None; let meas = measure!(@make_meas test, //T(a, Some("one")), T(b, None), t(c, "three"), S(a, Some("one".to_string())), S(b, None), s(c, "three".to_string()), - I(d, Some(4)), I(e, None), i(f, 6), - F(g, Some(7.0)), F(h, None), f(i, 9.0), + I(d, Some(4)), I(e), i(f, 6), + F(g, Some(7.0)), F(h), f(i, 9.0), ); assert_eq!(meas.get_field("a").unwrap(), &OwnedValue::String("one".to_string())); assert!(meas.get_field("b").is_none());