You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Remove str::is_whitespace and str::is_alphanumeric #49657
Strongly prefer to have this method (unsurprisngly). I assumed it was an oversight that it was missing; I've probably tried s.is_whitespace() a half dozen times and then been surprised it was nightly only.
We could add a system to be able to add suggestions to missing method errors. Thus the use of is_whitespace would suggest .chars().all(char::is_whitespace)
Deleting these methods should of course not be blocked on such a system being in place
The second string uses a Combining Diaeresis with an o instead of an ö. Sure, the explicit variant chars().all(...) also has this problem, but being explicit makes the bug a bit less subtle. Having is_alphanumeric on a string might suggest that the method "does the right thing" (whatever that is) instead of looking at characters individually.
I think str::is_whitespace doesn't have a problem with subtle Unicode bugs, but I don't quite like the name: is_whitespace sounds singular to me and thus doesn't translate perfectly to a string.
If you are interested, I did a bit of research how .chars().all(char::is_whitespace) is called in other languages (sometimes with libraries):
Activity
withoutboats commentedon Apr 4, 2018
Strongly prefer to have this method (unsurprisngly). I assumed it was an oversight that it was missing; I've probably tried
s.is_whitespace()a half dozen times and then been surprised it was nightly only.oli-obk commentedon Apr 5, 2018
We could add a system to be able to add suggestions to missing method errors. Thus the use of
is_whitespacewould suggest.chars().all(char::is_whitespace)Deleting these methods should of course not be blocked on such a system being in place
LukasKalbertodt commentedon Apr 5, 2018
@oli-obk I like this idea a lot! (independently from this discussion)
About
is_alphanumeric: I think I prefer to removestr::is_alphanumericas it might lead to subtle Unicode bugs. Example:The second string uses a Combining Diaeresis with an
oinstead of anö. Sure, the explicit variantchars().all(...)also has this problem, but being explicit makes the bug a bit less subtle. Havingis_alphanumericon a string might suggest that the method "does the right thing" (whatever that is) instead of looking at characters individually.I think
str::is_whitespacedoesn't have a problem with subtle Unicode bugs, but I don't quite like the name:is_whitespacesounds singular to me and thus doesn't translate perfectly to a string.If you are interested, I did a bit of research how
.chars().all(char::is_whitespace)is called in other languages (sometimes with libraries):blank?StringUtils.isBlankisspaceIsNullOrWhiteSpaceMaybe
str::is_blankis a better name for Rust?Auto merge of #50088 - alexcrichton:std-tweaks, r=sfackler