From 7a65f0a71f66fcca38741da7c5d28d59df7924b1 Mon Sep 17 00:00:00 2001 From: Chad Greenburg Date: Wed, 20 Oct 2021 19:55:57 -0500 Subject: [PATCH] feat: automatically convert Vec into HashMap --- src/macros.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/macros.rs b/src/macros.rs index 7ae36fec..11581031 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -162,7 +162,14 @@ macro_rules! histogram_opts { ($NAME:expr, $HELP:expr, $BUCKETS:expr, $CONST_LABELS:expr $(,)?) => {{ let hopts = histogram_opts!($NAME, $HELP, $BUCKETS); - hopts.const_labels($CONST_LABELS) + + let lbs = HashMap::::new(); + $( + let mut lbs = lbs; + lbs.extend($CONST_LABELS.iter().map(|(k, v)| ((*k).into(), (*v).into()))); + )* + + hopts.const_labels(lbs) }}; }