-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
FromWorld
derive macro
#17352
FromWorld
derive macro
#17352
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add some docs to FromWorld
explaining how to use the derive macro?
69d8856
to
14b3d88
Compare
let Data::Struct(DataStruct { fields, .. }) = &ast.data else { | ||
return syn::Error::new( | ||
Span::call_site(), | ||
"#[derive(FromWorld)]` only supports structs", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Totally not required for this PR but one thing that just occurred to me is that we could add a #[from_world]
helper that works sorta like Default
's #[default]
, allowing for enums to utilize this derive macro too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ooh good idea. Might need to rework the internals a bit for that, so might be good for a followup :)
But I also might get bored and do it anyway lol
simple derive macro for `FromWorld`. Going to be needed for composable pipeline specializers but probably a nice thing to have regardless ## Testing simple manual testing, nothing seemed to blow up. I'm no proc macro pro though, so there's a chance I've mishandled spans somewhere or something.
simple derive macro for
FromWorld
. Going to be needed for composable pipeline specializers but probably a nice thing to have regardlessTesting
simple manual testing, nothing seemed to blow up. I'm no proc macro pro though, so there's a chance I've mishandled spans somewhere or something.