Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove overlap between manual_split_once and needless_splitn #8631

Merged
merged 1 commit into from
Apr 10, 2022

Conversation

Alexendoo
Copy link
Member

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;

@rust-highfive
Copy link

r? @xFrednet

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Apr 4, 2022
Copy link
Member

@xFrednet xFrednet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good to me, a solid improvement and nice refactoring! Just one small NIT and then it's ready to be merged. 👍

And thank you for your patience, while waiting for a review. I appreciate it! 🙃

clippy_lints/src/methods/str_splitn.rs Show resolved Hide resolved
Also fixes some incorrect suggestions for rsplitn
@xFrednet
Copy link
Member

Looks good to me, thank you very much for the update 🙃

@bors r+

@bors
Copy link
Contributor

bors commented Apr 10, 2022

📌 Commit 6fba897 has been approved by xFrednet

@bors
Copy link
Contributor

bors commented Apr 10, 2022

⌛ Testing commit 6fba897 with merge 5344236...

@bors
Copy link
Contributor

bors commented Apr 10, 2022

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: xFrednet
Pushing 5344236 to master...

@bors bors merged commit 5344236 into rust-lang:master Apr 10, 2022
@Alexendoo Alexendoo deleted the splitn-overlap branch April 10, 2022 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants