Closed
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
}
}