Skip to content

Document str::split behavior with contiguous separators #26130

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

Merged
merged 1 commit into from
Jun 10, 2015

Conversation

steveklabnik
Copy link
Member

This can be confusing when whitespace is the separator

Fixes #25986

This can be confusing when whitespace is the separator

Fixes rust-lang#25986
@rust-highfive
Copy link
Contributor

r? @huonw

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

@alexcrichton
Copy link
Member

@bors: r+ 96c7a6b

/// It does _not_ give you:
///
/// ```rust,ignore
/// assert_eq!(d, &["a", "b", "c"]);
Copy link
Member

Choose a reason for hiding this comment

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

"Does not give" you isn't that too confusing to bring up? What if we instead show that d.filter(|s| !s.is_empty()) produces this?

Copy link
Member Author

Choose a reason for hiding this comment

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

I thought contrasting with another common way it could be implemented would be clarifying

Copy link
Member

Choose a reason for hiding this comment

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

Ok. I realize I'm not the target audience, I don't actually know what style works best to communicate.

I would not use this style myself -- I would not mention confusion, I would just underscore the facts as well as possible.

Just my thoughts -- it's awesome this PR addresses this in some way, by underscoring the facts of how this function works!

Copy link
Member Author

Choose a reason for hiding this comment

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

I am usually on that side too, but this seems like a pretty common confusion.

Copy link
Member

Choose a reason for hiding this comment

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

How about assert!(d != &["a", "b", "c"])?

@bors
Copy link
Collaborator

bors commented Jun 10, 2015

⌛ Testing commit 96c7a6b with merge e954031...

bors added a commit that referenced this pull request Jun 10, 2015
This can be confusing when whitespace is the separator

Fixes #25986
@bors bors merged commit 96c7a6b into rust-lang:master Jun 10, 2015
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