Open
Description
I have some type (e.g. struct), that I would like to derive label(s) from, e.g.
struct X {
abc: u64,
def: &'static str
}
let x = X { abc: 123, def: "a" };
increment_counter!("foo", x);
Could be equivalent to:
increment_counter!("foo", "x_abc" => 123, "x_def" => "a");
I tried using IntoLabels
, unfortunately it does not compose:
increment_counter!("foo", x, y); // Does not work
increment_counter!("foo", x, "x" => "y"); // Does not work
What are your thoughts on extending the macro syntax?
Perhaps another alternative would be to define a macro that would expand values of X
into key => value
pairs, but I was not able to come up with that -- this would already help and be more efficient (but less ergonomic) as it would also avoid the IntoLabels
Vec
allocation.