Replies: 1 comment
-
|
It shouldn't lint there because it would become recursive, for that it looks like there's an open issue #12463 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Note: this is essentially just a port of a question I already asked on StackOverflow, to no avail. I figured that a question about clippy may be better answered here!
Let us consider the following simple program:
This works fine, and
clippydoesn't complain at all. Now, for convenience purposes, I would like to be able to dofirst_struct * &second_struct, which is why I also defined the trait forMyStructlike so:Though this works,
clippynow complains with:Reading the linked page, it says:
However, in my case, I don't use the
==comparator, but the*operator, so the proposed fix doesn't really make sense here as far as I can tell.Note that the warning disappears when removing the
Copytrait forMyStruct. On the one hand, this seems logical, since I can cheaply copy the object, the implementation for owned values should be identical to that of borrowed ones. But on the other hand, I do have to implement theMultrait forMyStruct, as the program otherwise doesn't compile, like this one:Is there a more idiomatic way to write this code, or should I just silence this warning?
Beta Was this translation helpful? Give feedback.
All reactions