]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/src/docs/needless_arbitrary_self_type.txt
Auto merge of #98559 - jackh726:remove-reempty, r=oli-obk
[rust.git] / src / tools / clippy / src / docs / needless_arbitrary_self_type.txt
1 ### What it does
2 The lint checks for `self` in fn parameters that
3 specify the `Self`-type explicitly
4 ### Why is this bad?
5 Increases the amount and decreases the readability of code
6
7 ### Example
8 ```
9 enum ValType {
10     I32,
11     I64,
12     F32,
13     F64,
14 }
15
16 impl ValType {
17     pub fn bytes(self: Self) -> usize {
18         match self {
19             Self::I32 | Self::F32 => 4,
20             Self::I64 | Self::F64 => 8,
21         }
22     }
23 }
24 ```
25
26 Could be rewritten as
27
28 ```
29 enum ValType {
30     I32,
31     I64,
32     F32,
33     F64,
34 }
35
36 impl ValType {
37     pub fn bytes(self) -> usize {
38         match self {
39             Self::I32 | Self::F32 => 4,
40             Self::I64 | Self::F64 => 8,
41         }
42     }
43 }
44 ```