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

Clarify last element in str.{r,}splitn documentation #36930

Merged
merged 1 commit into from
Oct 6, 2016
Merged

Clarify last element in str.{r,}splitn documentation #36930

merged 1 commit into from
Oct 6, 2016

Conversation

angelsl
Copy link
Contributor

@angelsl angelsl commented Oct 3, 2016

An attempt at #36202.

I'm not sure if my wording is actually clearer, to be honest...

@rust-highfive
Copy link
Collaborator

r? @brson

(rust_highfive has picked a reviewer for you, use r? to override)

@@ -1055,8 +1055,8 @@ impl str {
/// 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
Copy link
Member

Choose a reason for hiding this comment

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

I think, as a whole, your changes are an improvement and make it easier to understand this concept.

If a countth substring

I personally stumbled on this though. It took me a few re-reads to understand this is talking about "substring with countth number of items". I can't think of a better suggestion at the moment without making it too verbose. Going to think about this...

Copy link
Member

Choose a reason for hiding this comment

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

For non-english reader, this is particurlarly hard.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How about this:

If count substrings are returned, the last substring i.e. the countth substring will contain the remainder of the string.

Copy link
Member

Choose a reason for hiding this comment

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

I think that's better. Or maybe even:

If count substrings are returned, the last substring (the countth substring) will contain the remainder of the string.

What do you think @GuillaumeGomez ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Crazy idea: rename the parameter from count to n (slice::splitn's parameter is called n). Then we can say "the nth substring" which is probably easier to parse.

Copy link
Member

Choose a reason for hiding this comment

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

@frewsxcv: I prefer @durka's proposition. :)

Copy link
Member

Choose a reason for hiding this comment

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

I'm generally against single letter variable names, but considering the method name is splitn, I think n makes sense. What do you think @angelsl? If you're alright with it, can you rename the parameter and update the instances of count in the doc comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good to me. I've amended the commit.

@frewsxcv
Copy link
Member

frewsxcv commented Oct 5, 2016

Looks great, thanks! r=me

@GuillaumeGomez
Copy link
Member

@bors: r=frewsxcv rollup

@bors
Copy link
Contributor

bors commented Oct 5, 2016

📌 Commit a4e9c39 has been approved by frewsxcv

sophiajt pushed a commit to sophiajt/rust that referenced this pull request 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...
bors added a commit that referenced this pull request Oct 6, 2016
@bors bors merged commit a4e9c39 into rust-lang:master Oct 6, 2016
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.

7 participants