-
Notifications
You must be signed in to change notification settings - Fork 190
Open
Labels
C-coreComponent: core functionality such as traits, etc.Component: core functionality such as traits, etc.C-macrosComponent: macros.Component: macros.E-complexEffort: complex.Effort: complex.T-ergonomicsType: ergonomics.Type: ergonomics.T-experimentType: experiment.Type: experiment.
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.
Metadata
Metadata
Assignees
Labels
C-coreComponent: core functionality such as traits, etc.Component: core functionality such as traits, etc.C-macrosComponent: macros.Component: macros.E-complexEffort: complex.Effort: complex.T-ergonomicsType: ergonomics.Type: ergonomics.T-experimentType: experiment.Type: experiment.