RS.CLIPPY.NEEDLESS_SPLITN
Usages of `str::splitn` that can be replaced with `str::split`
This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: needless_splitn. Copyright ©2025 The Rust Team. All rights reserved.
What it does
Checks for usage 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();