diff options
Diffstat (limited to 'src/tools/clippy/src/docs/needless_splitn.txt')
-rw-r--r-- | src/tools/clippy/src/docs/needless_splitn.txt | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/tools/clippy/src/docs/needless_splitn.txt b/src/tools/clippy/src/docs/needless_splitn.txt new file mode 100644 index 000000000..b10a84fbc --- /dev/null +++ b/src/tools/clippy/src/docs/needless_splitn.txt @@ -0,0 +1,16 @@ +### What it does +Checks for usages of `str::splitn` (or `str::rsplitn`) where using `str::split` would be the same. +### Why is this bad? +The function `split` is simpler and there is no performance difference in these cases, considering +that both functions return a lazy iterator. +### Example +``` +let str = "key=value=add"; +let _ = str.splitn(3, '=').next().unwrap(); +``` + +Use instead: +``` +let str = "key=value=add"; +let _ = str.split('=').next().unwrap(); +```
\ No newline at end of file |