-
Notifications
You must be signed in to change notification settings - Fork 13.3k
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
Conversation
This can be confusing when whitespace is the separator Fixes rust-lang#25986
r? @huonw (rust_highfive has picked a reviewer for you, use r? to override) |
/// It does _not_ give you: | ||
/// | ||
/// ```rust,ignore | ||
/// assert_eq!(d, &["a", "b", "c"]); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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"])
?
This can be confusing when whitespace is the separator Fixes #25986
This can be confusing when whitespace is the separator
Fixes #25986