-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Derive clone #18811
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
base: main
Are you sure you want to change the base?
Derive clone #18811
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.
We should probably also add tests for all possible variants of ComponentCloneBehavior
to ensure everything parses and works as intended (or at least just the parsing part).
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.
Just one nitpick, otherwise looks good to me!
if attrs.relationship_target.is_some() && attrs.clone_behavior.is_some() { | ||
return Err(syn::Error::new( | ||
attrs.clone_behavior.span(), | ||
format!("A Relationship Target already has it's own clone behavior, please remove `clone_behavior = {}`", attrs.clone_behavior.as_ref().unwrap().to_token_stream()), |
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.
Nit: I don't think you need to provide the token value. Any clone_behavior
would result in this error. Plus I believe printing the token streams can sometimes look different than the input (at least in the case of a Custom
behavior).
format!("A Relationship Target already has it's own clone behavior, please remove `clone_behavior = {}`", attrs.clone_behavior.as_ref().unwrap().to_token_stream()), | |
"A Relationship Target already has its own clone behavior, please remove `clone_behavior`", |
Allow Derive(Component) to specify a clone_behavior