summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/src/docs/mutex_integer.txt
blob: f9dbdfb904c9a91a681451e936b3ec22a0321e58 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
### What it does
Checks for usages of `Mutex<X>` where `X` is an integral
type.

### Why is this bad?
Using a mutex just to make access to a plain integer
sequential is
shooting flies with cannons. `std::sync::atomic::AtomicUsize` is leaner and faster.

### Known problems
This lint cannot detect if the mutex is actually used
for waiting before a critical section.

### Example
```
let x = Mutex::new(0usize);
```

Use instead:
```
let x = AtomicUsize::new(0usize);
```