-
-
Notifications
You must be signed in to change notification settings - Fork 330
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Derive Named #2758
Comments
Contrary to what the code is now, I think we should not directly use the struct name for its name. If derived macro can do that then it's good to have |
are you interested in implementing this? |
That is a fair point. It may however be hard to implement:
If I read the code correctly, |
Even just implementing the bare minimum of this however seems like a lot of work, and I don't have the capacity to do so at the moment. There is still a point to be made that a macro that just implements impl Named for MyNamedThing {
fn name(&self) -> &Cow<'static, str> {
&Cow::Borrowed("MyNamedThing")
}
} |
For this one, the name can just be local to the process. no need to synchronize |
Do you want this for now? |
I think we'd want to create a |
That would be the optimal way, but it's only possible in the most trivial cases. The issue is that I need to be able to automatically derive all constructor functions for the struct as well, to be able to create an additional struct part containing the structs unique name. So this reasonably only works for constructors where all struct items are passed to the constructor and directly stored in the struct, without any additional logic (because that cannot generally be derived). I'm not sure the added code complexity is worth it for a solution that only works for a limited subset of targeted structs. |
A lot of structs within LibAFL implement
Named
. And all of those are done manually, leading to a lot of code duplication. Would it make sense to create a derive macro that implements it based on the struct name?Is there a reason this doesn't exist already?
The text was updated successfully, but these errors were encountered: