3
Remove overlap between `manual_split_once` and `needless_splitn` by Alexendoo ·...
source link: https://github.com/rust-lang/rust-clippy/pull/8631
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
changelog: Remove overlap between [manual_split_once
] and [needless_splitn
]. Fixes some incorrect rsplitn
suggestions for [manual_split_once
]
Things that can trigger needless_splitn
no longer trigger manual_split_once
, e.g.
s.[r]splitn(2, '=').next(); s.[r]splitn(2, '=').nth(0); s.[r]splitn(3, '=').next_tuple();
Fixes some suggestions:
let s = "should not match"; s.rsplitn(2, '.').nth(1); // old -> Some("should not match") Some(s.rsplit_once('.').map_or(s, |x| x.0)); // new -> None s.rsplit_once('.').map(|x| x.0); s.rsplitn(2, '.').nth(1)?; // old -> "should not match" s.rsplit_once('.').map_or(s, |x| x.0); // new -> early returns s.rsplit_once('.')?.0;
xFrednet reacted with heart emoji
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK