]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/src/docs/trait_duplication_in_bounds.txt
Auto merge of #101969 - reez12g:issue-101306, r=reez12g
[rust.git] / src / tools / clippy / src / docs / trait_duplication_in_bounds.txt
1 ### What it does
2 Checks for cases where generics are being used and multiple
3 syntax specifications for trait bounds are used simultaneously.
4
5 ### Why is this bad?
6 Duplicate bounds makes the code
7 less readable than specifying them only once.
8
9 ### Example
10 ```
11 fn func<T: Clone + Default>(arg: T) where T: Clone + Default {}
12 ```
13
14 Use instead:
15 ```
16 fn func<T: Clone + Default>(arg: T) {}
17
18 // or
19
20 fn func<T>(arg: T) where T: Clone + Default {}
21 ```
22
23 ```
24 fn foo<T: Default + Default>(bar: T) {}
25 ```
26 Use instead:
27 ```
28 fn foo<T: Default>(bar: T) {}
29 ```
30
31 ```
32 fn foo<T>(bar: T) where T: Default + Default {}
33 ```
34 Use instead:
35 ```
36 fn foo<T>(bar: T) where T: Default {}
37 ```