]> git.lizzy.rs Git - rust.git/blob - src/docs/suspicious_arithmetic_impl.txt
[Arithmetic] Consider literals
[rust.git] / src / docs / suspicious_arithmetic_impl.txt
1 ### What it does
2 Lints for suspicious operations in impls of arithmetic operators, e.g.
3 subtracting elements in an Add impl.
4
5 ### Why is this bad?
6 This is probably a typo or copy-and-paste error and not intended.
7
8 ### Example
9 ```
10 impl Add for Foo {
11     type Output = Foo;
12
13     fn add(self, other: Foo) -> Foo {
14         Foo(self.0 - other.0)
15     }
16 }
17 ```