-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
<ctype.h> functions for AsciiExt #39658
Comments
* `is_ascii_alphabetic` * `is_ascii_uppercase` * `is_ascii_lowercase` * `is_ascii_alphanumeric` * `is_ascii_digit` * `is_ascii_hexdigit` * `is_ascii_punctuation` * `is_ascii_graphic` * `is_ascii_whitespace` * `is_ascii_control` This addresses issue rust-lang#39658.
Add equivalents of C's <ctype.h> functions to AsciiExt. * `is_ascii_alphabetic` * `is_ascii_uppercase` * `is_ascii_lowercase` * `is_ascii_alphanumeric` * `is_ascii_digit` * `is_ascii_hexdigit` * `is_ascii_punctuation` * `is_ascii_graphic` * `is_ascii_whitespace` * `is_ascii_control` This addresses issue rust-lang#39658. Lightly tested on x86-64-linux. tidy complains about the URLs in the documentation making lines too long, I don't know what to do about that.
Add equivalents of C's <ctype.h> functions to AsciiExt. * `is_ascii_alphabetic` * `is_ascii_uppercase` * `is_ascii_lowercase` * `is_ascii_alphanumeric` * `is_ascii_digit` * `is_ascii_hexdigit` * `is_ascii_punctuation` * `is_ascii_graphic` * `is_ascii_whitespace` * `is_ascii_control` This addresses issue rust-lang#39658. Lightly tested on x86-64-linux. tidy complains about the URLs in the documentation making lines too long, I don't know what to do about that.
Add equivalents of C's <ctype.h> functions to AsciiExt. * `is_ascii_alphabetic` * `is_ascii_uppercase` * `is_ascii_lowercase` * `is_ascii_alphanumeric` * `is_ascii_digit` * `is_ascii_hexdigit` * `is_ascii_punctuation` * `is_ascii_graphic` * `is_ascii_whitespace` * `is_ascii_control` This addresses issue rust-lang#39658. Lightly tested on x86-64-linux. tidy complains about the URLs in the documentation making lines too long, I don't know what to do about that.
Add equivalents of C's <ctype.h> functions to AsciiExt. * `is_ascii_alphabetic` * `is_ascii_uppercase` * `is_ascii_lowercase` * `is_ascii_alphanumeric` * `is_ascii_digit` * `is_ascii_hexdigit` * `is_ascii_punctuation` * `is_ascii_graphic` * `is_ascii_whitespace` * `is_ascii_control` This addresses issue rust-lang#39658. Lightly tested on x86-64-linux. tidy complains about the URLs in the documentation making lines too long, I don't know what to do about that.
Stabilize? I just wrote |
There was a request over in #39659 to deprecate |
What's the status here? Could I try to "deprecate AsciiExt and convert all the methods to intrinsics on |
From my end it's just lack of time. I think the team would be glad to at
least look at a patch if you made one.
|
Right now What do you think? |
I’ve definitely used |
CC @alexcrichton / @rust-lang/libs for FCP to stabilize as inherent methods: #44042 |
@rfcbot fcp merge |
Team member @aturon has proposed to merge this. The next step is review by the rest of the tagged teams: Concerns:
Once these reviewers reach consensus, this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
The semantics of e.g.
Would it be bad to require the user to be more explicit in some of these cases? s.bytes().all(|b| b.is_ascii_hexdigit()) @rfcbot concern str and [u8] methods |
Discussed at the libs triage meeting today, we're going to scope this issue to be blocked on #44042 and then we'll stabilize these methods only on the |
Any update here? |
Rust 1.24 was recently released with these methods available as inherent methods of I think we can now deprecate the |
Reopened as per request on IRC. |
Is it still the plan to get at least |
@zbraniecki We decided that we prefer the explicit version of |
Deprecation PR for the |
The trait and some of its methods are stable and will remain. Some of the newer methods are unstable and can be removed later. Fixes rust-lang#39658
…excrichton Deprecate the AsciiExt trait in favor of inherent methods The trait and some of its methods are stable and will remain. Some of the newer methods are unstable and can be removed later. Fixes rust-lang#39658
…excrichton Deprecate the AsciiExt trait in favor of inherent methods The trait and some of its methods are stable and will remain. Some of the newer methods are unstable and can be removed later. Fixes rust-lang#39658
Shouldn't this issue also track "removing of unstable |
I don’t know how useful it is to track such features individually. We can occasionally do a pass on the entire standard library looking for items that are both unstable and have been deprecated for a while. |
@SimonSapin Ah, I missed the fact that the unstable methods were also marked deprecated. That makes sense then! |
I'm disappointed that there is now no officially-supported version of |
@BartMassey IMO However, what one might be looking for, and not realize that Forcing users to write (Maybe |
That is an interesting point. There are certainly a number of fine distinctions that can be drawn here: one might reasonably expect that That said, I still feel like the There's an underlying problem here in that anything we do to make ASCII more of a first-class citizen is a step toward encouraging folks to routinely write ASCII-only programs. Nobody wants that. Having said that, tutorials and examples almost always use and pretty much depend on ASCII: things like Exercism and the Advent Of Code series have caused me an occasional "any other language" kind of feeling because the exercises just assume quality ASCII support. Asking newer users to understand how to write the appropriate iterators to complete these exercises seems to me like it might have its own set of issues. I don't know. I guess I just need to identify or write a crate that has good support for ASCII-only strings and chars and start using it in situations where that's what I'm working with. For now, |
For what it’s worth the addition of
Interesting, because this behavior is neither Anyway, it’s always possible to add more methods but a closed issue may not be the best place to propose them. |
As discussed at https://internals.rust-lang.org/t/improvements-to-asciiext/4689 I have added
is_ascii_*
equivalents of most (not quite all) of C'sctype.h
'sisxxx
functions to the AsciiExt trait.The new functions are
is_ascii_alphabetic
is_ascii_uppercase
is_ascii_lowercase
is_ascii_alphanumeric
is_ascii_digit
is_ascii_hexdigit
is_ascii_punctuation
is_ascii_graphic
is_ascii_whitespace
(matches the Infra Standard definition of ASCII whitespace, not POSIX)is_ascii_control
They are implemented for
char
,u8
,str
, and[u8]
, and, for backward compatibility with external trait implementations, have default implementations that callunimplemented!()
.PR to follow, but I needed to file this bug in order to get an issue number to put in the stability annotations.
The text was updated successfully, but these errors were encountered: