summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/src/docs/char_lit_as_u8.txt
blob: 00d60b9a451b9f4b82be87cded214d1a7b930b55 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
### What it does
Checks for expressions where a character literal is cast
to `u8` and suggests using a byte literal instead.

### Why is this bad?
In general, casting values to smaller types is
error-prone and should be avoided where possible. In the particular case of
converting a character literal to u8, it is easy to avoid by just using a
byte literal instead. As an added bonus, `b'a'` is even slightly shorter
than `'a' as u8`.

### Example
```
'x' as u8
```

A better version, using the byte literal:

```
b'x'
```