RS.CLIPPY.SUSPICIOUS_SPLITN

Checks for `.splitn(0, ..)` and `.splitn(1, ..)`

This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: suspicious_splitn. Copyright ©2025 The Rust Team. All rights reserved.

What it does

Checks for calls to [splitn] (https://doc.rust-lang.org/std/primitive.str.html#method.splitn) and related functions with either zero or one splits.

Why is this bad?

These calls don't actually split the value and are likely to be intended as a different number.

Example

for x in s.splitn(1, ":") {
    // ..
}

Use instead:

for x in s.splitn(2, ":") {
    // ..
}