style: use Self to avoid unnecessary repetition#3396
Conversation
In `impl`s, `Self` can be used instead of the struct/enum being implemented, to reduce unnecessary repetition. This commit uses `Self` as often as possible. This fixes the `use_self` clippy lint.
|
Copying over the previous discussion from #3394
|
|
Yeah, let's be a bit more conservative and not change any of the places that David had some concerns about. You can still enable the lint, just |
NOTE: This commit adds multiple `#[allow]`s where Clippy would otherwise warn about `Self` being allowed.
mladedav
left a comment
There was a problem hiding this comment.
I think everything here is fine, if I didn't miss something, it's really just constructors and enum variants (and a few signatures).
|
With all checks passing, this is ready to merge 👌 |
|
@jplatte if you want to change some of the allows to |
|
Thanks everyone! |
Motivation
This PR is part of the broader PR #3394 (Activate more lints)
Repeating type names over and over again quickly becomes a problem if the name of the type ever changes, or a refactored is required. It also makes it more difficult to copy code from one method to another.
Solution
In
impls,Selfcan be used instead of the struct/enum being implemented, to reduce unnecessary repetition. This PR usesSelfas often as possible. This fixes theuse_selfclippy lint.