-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
A-lintArea: New lintsArea: New lintsL-styleLint: Belongs in the style lint groupLint: Belongs in the style lint groupgood first issueThese issues are a good way to get started with ClippyThese issues are a good way to get started with Clippy
Description
What it does
Warns when methods have the same name as their type.
Idiomatic Rust typically uses new
, from
, or from…
to create a new value of the type.
Categories (optional)
- Kind: style
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
struct Type {}
impl Type {
pub fn type() -> Type {
Type
}
}
Could be written as:
struct Type {}
impl Type {
pub fn new() -> Type {
Type
}
}
Metadata
Metadata
Assignees
Labels
A-lintArea: New lintsArea: New lintsL-styleLint: Belongs in the style lint groupLint: Belongs in the style lint groupgood first issueThese issues are a good way to get started with ClippyThese issues are a good way to get started with Clippy