Warn against Type::type methods #7142
Labels
A-lint
Area: New lints
good-first-issue
These issues are a good way to get started with Clippy
L-style
Lint: Belongs in the style lint group
What it does
Warns when methods have the same name as their type.
Idiomatic Rust typically uses
new
,from
, orfrom…
to create a new value of the type.Categories (optional)
It is easier to read and understand the code, because it is more consistent.
Repeating the name of the type is redundant.
Drawbacks
There might be reasons to repeat the type name?
Example
Could be written as:
The text was updated successfully, but these errors were encountered: