summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/src/docs/trait_duplication_in_bounds.txt
blob: 509736bb36444a10131be93a173eef72903ffb9b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
### What it does
Checks for cases where generics are being used and multiple
syntax specifications for trait bounds are used simultaneously.

### Why is this bad?
Duplicate bounds makes the code
less readable than specifying them only once.

### Example
```
fn func<T: Clone + Default>(arg: T) where T: Clone + Default {}
```

Use instead:
```
fn func<T: Clone + Default>(arg: T) {}

// or

fn func<T>(arg: T) where T: Clone + Default {}
```

```
fn foo<T: Default + Default>(bar: T) {}
```
Use instead:
```
fn foo<T: Default>(bar: T) {}
```

```
fn foo<T>(bar: T) where T: Default + Default {}
```
Use instead:
```
fn foo<T>(bar: T) where T: Default {}
```