]> git.lizzy.rs Git - rust.git/blob - src/docs/cmp_owned.txt
Rollup merge of #104595 - compiler-errors:poly-existential-predicate, r=lcnr
[rust.git] / src / docs / cmp_owned.txt
1 ### What it does
2 Checks for conversions to owned values just for the sake
3 of a comparison.
4
5 ### Why is this bad?
6 The comparison can operate on a reference, so creating
7 an owned value effectively throws it away directly afterwards, which is
8 needlessly consuming code and heap space.
9
10 ### Example
11 ```
12 if x.to_owned() == y {}
13 ```
14
15 Use instead:
16 ```
17 if x == y {}
18 ```