]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/src/docs/self_named_constructors.txt
Auto merge of #101615 - compiler-errors:rpitit-perf, r=oli-obk
[rust.git] / src / tools / clippy / src / docs / self_named_constructors.txt
1 ### What it does
2 Warns when constructors have the same name as their types.
3
4 ### Why is this bad?
5 Repeating the name of the type is redundant.
6
7 ### Example
8 ```
9 struct Foo {}
10
11 impl Foo {
12     pub fn foo() -> Foo {
13         Foo {}
14     }
15 }
16 ```
17 Use instead:
18 ```
19 struct Foo {}
20
21 impl Foo {
22     pub fn new() -> Foo {
23         Foo {}
24     }
25 }
26 ```