about summary refs log tree commit diff
path: root/src/docs/unit_cmp.txt
blob: 6f3d62010dc51ab1ee3a5207b961c67077c9ac28 (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
### What it does
Checks for comparisons to unit. This includes all binary
comparisons (like `==` and `<`) and asserts.

### Why is this bad?
Unit is always equal to itself, and thus is just a
clumsily written constant. Mostly this happens when someone accidentally
adds semicolons at the end of the operands.

### Example
```
if {
    foo();
} == {
    bar();
} {
    baz();
}
```
is equal to
```
{
    foo();
    bar();
    baz();
}
```

For asserts:
```
assert_eq!({ foo(); }, { bar(); });
```
will always succeed