summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/src/docs/is_digit_ascii_radix.txt
blob: 9f11cf43054feddbe543d066c02597c7f392d233 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
### What it does
Finds usages of [`char::is_digit`](https://doc.rust-lang.org/stable/std/primitive.char.html#method.is_digit) that
can be replaced with [`is_ascii_digit`](https://doc.rust-lang.org/stable/std/primitive.char.html#method.is_ascii_digit) or
[`is_ascii_hexdigit`](https://doc.rust-lang.org/stable/std/primitive.char.html#method.is_ascii_hexdigit).

### Why is this bad?
`is_digit(..)` is slower and requires specifying the radix.

### Example
```
let c: char = '6';
c.is_digit(10);
c.is_digit(16);
```
Use instead:
```
let c: char = '6';
c.is_ascii_digit();
c.is_ascii_hexdigit();
```