We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Describe the bug The following code will fail to derive.
To Reproduce
use derivative::*; #[derive(Derivative, Debug)] #[derivative(Clone(bound = ""), Copy(bound = ""))] pub struct T<'a, A> { a: &'a String, b: &'a A, }
Expected behavior derive succeeds.
derive
Errors
error[E0308]: mismatched types --> src/main.rs:3:10 | 3 | #[derive(Derivative, Debug)] | ^^^^^^^^^^ | | | expected `&String`, found struct `String` | help: consider borrowing here: `&Derivative`
Version (please complete the following information):
The text was updated successfully, but these errors were encountered:
This will be fixed if the macro expansion uses UFCS Clone::clone(arg) instead of arg.clone(), ie #111
Clone::clone(arg)
arg.clone()
As I wrote there, the macro can be forced to use UFCS by annotating the borrow fields with clone_with = "Clone::clone", which for OP's case means:
clone_with = "Clone::clone"
use derivative::*; #[derive(Derivative, Debug)] #[derivative(Clone(bound = ""), Copy(bound = ""))] pub struct T<'a, A> { #[derivative(Clone(clone_with = "Clone::clone"))] a: &'a String, #[derivative(Clone(clone_with = "Clone::clone"))] b: &'a A, }
Sorry, something went wrong.
No branches or pull requests
Describe the bug
The following code will fail to derive.
To Reproduce
Expected behavior
derive
succeeds.Errors
Version (please complete the following information):
The text was updated successfully, but these errors were encountered: