-
Notifications
You must be signed in to change notification settings - Fork 12.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
fn pointer type is not Clone when containing a parameter with an unspecified lifetime #20468
Comments
I have got the same error, is this a bug or what? I just can not clone any function that takes a reference. |
I ran into the same error. |
Note that if you contain types in the fn signature that are from your own crate, you can provide an explicit implementation yourself as a workaround. That doesn't solve this in the general case though, such as in the example in the first post, since neither &str nor String are from your own crate. |
Traige: new code:
|
The following snippet fails to compile.
Yielding the error...
However, it works when the argument reference is given a lifetime specifier (as below).
Structs/enums cloneability should not rely on the lifetime of a bare function's arguments, since the argument's lifetime is relative to the function, not the struct.
Compiler version details:
The text was updated successfully, but these errors were encountered: