In my proc macro I want to use pass in an operator for an equation such as
obj1.as_i64() > obj2.as_i64();
where the > is a value passed on.
used something like this
#[derive(Evaluate(>))]
pub struct GreaterThan(String);
what I would like to know is how could I define the parameter, get the parameter and use it in place of the ">"
Derive macros don't support direct parameters like that. But you can use a helper attribute
https://doc.rust-lang.org/reference/procedural-macros.html#derive-macro-helper-attributes
so you could write stuff like
#[derive(Evaluate)]
#[evaluate(>)]
pub struct GreaterThan(String);
system
Closed
3
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.