]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/src/docs/chars_next_cmp.txt
Merge commit 'b52fb5234cd7c11ecfae51897a6f7fa52e8777fc' into clippyup
[rust.git] / src / tools / clippy / src / docs / chars_next_cmp.txt
1 ### What it does
2 Checks for usage of `.chars().next()` on a `str` to check
3 if it starts with a given char.
4
5 ### Why is this bad?
6 Readability, this can be written more concisely as
7 `_.starts_with(_)`.
8
9 ### Example
10 ```
11 let name = "foo";
12 if name.chars().next() == Some('_') {};
13 ```
14
15 Use instead:
16 ```
17 let name = "foo";
18 if name.starts_with('_') {};
19 ```