-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #8717 - Alexendoo:manual-split-once-manual-iter, r=dswi…
…j,xFrednet `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()?; ```
- Loading branch information
Showing
5 changed files
with
527 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.