Skip to content

Commit feb2546

Browse files
author
Chad Greenburg
committed
feat: automatically convert Vec into HashMap
Signed-off-by: Chad Greenburg <[email protected]>
1 parent d1528e1 commit feb2546

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/macros.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,14 @@ macro_rules! histogram_opts {
162162

163163
($NAME:expr, $HELP:expr, $BUCKETS:expr, $CONST_LABELS:expr $(,)?) => {{
164164
let hopts = histogram_opts!($NAME, $HELP, $BUCKETS);
165-
hopts.const_labels($CONST_LABELS)
165+
166+
let lbs = HashMap::<String, String>::new();
167+
$(
168+
let mut lbs = lbs;
169+
lbs.extend($CONST_LABELS.iter().map(|(k, v)| ((*k).into(), (*v).into())));
170+
)*
171+
172+
hopts.const_labels(lbs)
166173
}};
167174
}
168175

0 commit comments

Comments
 (0)