Skip to content

Commit

Permalink
feat: automatically convert Vec into HashMap
Browse files Browse the repository at this point in the history
  • Loading branch information
dkryptr committed Oct 21, 2021
1 parent d1528e1 commit 7a65f0a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/macros.rs
Expand Up @@ -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::<String, String>::new();
$(
let mut lbs = lbs;
lbs.extend($CONST_LABELS.iter().map(|(k, v)| ((*k).into(), (*v).into())));
)*

hopts.const_labels(lbs)
}};
}

Expand Down

0 comments on commit 7a65f0a

Please sign in to comment.