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

splitn documentation is not clear #36202

Closed
durka opened this issue Sep 1, 2016 · 4 comments
Closed

splitn documentation is not clear #36202

durka opened this issue Sep 1, 2016 · 4 comments

Comments

@durka
Copy link
Contributor

durka commented Sep 1, 2016

An iterator over substrings of the given string slice, separated by a pattern, restricted to returning at most count items.

The last element returned, if any, will contain the remainder of the string slice.

Is the last element yielded by the iterator the remainder after the N items, or is the remainder included in N? The answer is the latter, but I don't think it's clear. Or am I the problem here?

@frewsxcv
Copy link
Member

frewsxcv commented Sep 3, 2016

restricted to returning at most count items

This is supposed to indicate to the user how many items are returned by the iterator. Were you thinking splitn might returncount + 1 items?

@durka
Copy link
Contributor Author

durka commented Sep 3, 2016

That was my confusion. The examples make it clear though.

@frewsxcv
Copy link
Member

frewsxcv commented Oct 3, 2016

PR opened that attempts to address this: #36930

sophiajt pushed a commit to sophiajt/rust that referenced this issue Oct 6, 2016
Clarify last element in str.{r,}splitn documentation

An attempt at rust-lang#36202.

I'm not sure if my wording is actually clearer, to be honest...
@frewsxcv
Copy link
Member

I'm going to consider the changes in #36930 as resolving this. If someone feels otherwise, let me know and I'll reopen.

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

No branches or pull requests

3 participants