ed22428b72
`manual_split_once`: lint manual iteration of `SplitN` changelog: `manual_split_once`: lint manual iteration of `SplitN` Now lints: ```rust let mut iter = "a.b.c".splitn(2, '.'); let first = iter.next().unwrap(); let second = iter.next().unwrap(); let mut iter = "a.b.c".splitn(2, '.'); let first = iter.next()?; let second = iter.next()?; let mut iter = "a.b.c".rsplitn(2, '.'); let first = iter.next().unwrap(); let second = iter.next().unwrap(); let mut iter = "a.b.c".rsplitn(2, '.'); let first = iter.next()?; let second = iter.next()?; ``` It suggests (minus leftover whitespace): ```rust let (first, second) = "a.b.c".split_once('.').unwrap(); let (first, second) = "a.b.c".split_once('.')?; let (second, first) = "a.b.c".rsplit_once('.').unwrap(); let (second, first) = "a.b.c".rsplit_once('.')?; ``` Currently only lints if the statements are next to each other, as detecting the various kinds of shadowing was tricky, so the following won't lint ```rust let mut iter = "a.b.c".splitn(2, '.'); let something_else = 1; let first = iter.next()?; let second = iter.next()?; ``` |
||
---|---|---|
.. | ||
src | ||
Cargo.toml | ||
README.md |