]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/src/docs/needless_splitn.txt
:arrow_up: rust-analyzer
[rust.git] / src / tools / clippy / src / docs / needless_splitn.txt
1 ### What it does
2 Checks for usages of `str::splitn` (or `str::rsplitn`) where using `str::split` would be the same.
3 ### Why is this bad?
4 The function `split` is simpler and there is no performance difference in these cases, considering
5 that both functions return a lazy iterator.
6 ### Example
7 ```
8 let str = "key=value=add";
9 let _ = str.splitn(3, '=').next().unwrap();
10 ```
11
12 Use instead:
13 ```
14 let str = "key=value=add";
15 let _ = str.split('=').next().unwrap();
16 ```