Skip to content

Fix splitn bug #606

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

Closed
wants to merge 6 commits into from
Closed

Fix splitn bug #606

wants to merge 6 commits into from

Conversation

max-sixty
Copy link
Contributor

I think this should close #521

@max-sixty
Copy link
Contributor Author

I realized that splitn is copy pasted into two files, so changed in re_bytes.rs too

I don't know the repo well, but is that necessary? I made the code the same with Self::Item - would there be a way of reducing the actual duplication?

@max-sixty
Copy link
Contributor Author

Gentlest of reminders @BurntSushi !

@max-sixty
Copy link
Contributor Author

Could also use fuse here.

@max-sixty
Copy link
Contributor Author

Can anyone review this, even if not @BurntSushi ?

Copy link
Contributor

@ethanpailes ethanpailes left a comment

Choose a reason for hiding this comment

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

LGTM for what it is worth.

@danielparks
Copy link
Contributor

Unfortunately this PR breaks the case where there actually should be a trailing "" returned.

I’m working on a fix as part of #627, which deals with split() losing trailing ""s.

@danielparks
Copy link
Contributor

PR #628 submitted.

I did not pull in your (@max-sixty) changes to Self::Item since I wanted to keep it as limited as possible. Also, the other iterators I checked didn’t use Item. That could certainly use some magic help, but I think that needs to be another PR.

BurntSushi pushed a commit that referenced this pull request Jan 9, 2020
Corrects `/-/.splitn("a", 2)` to return `["a"]` instead of `["a", ""]`.
(`/-/` is shorthand for `Regex::new("-").unwrap()`.)

Fixes #521, Closes #606, Closes #628
BurntSushi pushed a commit that referenced this pull request Jan 9, 2020
Corrects `/-/.splitn("a", 2)` to return `["a"]` instead of `["a", ""]`.
(`/-/` is shorthand for `Regex::new("-").unwrap()`.)

Fixes #521, Closes #606, Closes #628
@BurntSushi BurntSushi closed this in 65d6bba Jan 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

splitn(.., 2) returning extra substring
3 participants