-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Changes in Ascii #14496
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
Changes in Ascii #14496
Conversation
Note that I already have an outstanding PR #14436 that makes changes to |
It's not so obvious what's correct when talking about these small primitive values, as all conversion is cheap, but For |
Why? I can say |
@kballard I thought it would be interesting to have What you say about What do you think about the questions at the end? |
We don't have opt-in built-in bounds yet. That's still pending See #13231. Today
There apparently already is one. |
@kballard Thanks for your feedback! The problem with the current |
What do you mean? |
@aochagavia The only reason to use a trait instead of just implementing the same methods is if you want to be generic over the trait. Looking at it, the only methods that I'm guessing you don't think make sense are |
Actually my concern is naming. If you implement the same trait, then you can be sure that naming will remain consistent. |
Also, when I wrote about Thanks again for your feedback! |
Ok, I suppose that's a good reason. Given that, I guess we can split |
@aochagavia What would this proposed |
We probably should. There's precedence in the other various primitive conversion methods (e.g. |
Because that's not really a character type classification. But I don't really have a compelling reason for omitting it, besides the fact that it doesn't correspond with any of the normal character classes (such as |
Sorry, I deleted my comment before you gave answer. I think I will open a new pull request... Thanks! |
@aochagavia Have you looked at my #14436? I'm concerned that you submitting a separate PR will conflict. Perhaps we should build your proposed changes on top of my PR instead of competing. |
I think it is a good idea, but I have never done it before. Can I just push commits to your pull request? |
@aochagavia You can't, but you can fetch my branch from my fork, add commits to it, push that to your own fork, and send me a link and I can update my PR. |
I think I will wait until your pr is merged. Alternatively you can Thanks again for your help with this!
|
@aochagavia I'm on board with implementing the changes myself. Just to clarify, this is what you want to do:
Anything else that I'm missing? I think we should probably also go ahead and remove Also, opinion on |
@kballard No problem, go ahead! Actually I would like the Additionaly, I think it would be good to have Another concern I have is the fact that |
Failing when the radix is greater than 36 is deliberate, because that's considered a programmer error, not an input error. I'm still not convinced that |
Breaking changes:
to_byte
toas_byte
to_char
toas_char
eq_ignore_case
(I don't think we want to have a special function for this when it is so easy to writea.to_lowercase() == b.to_lowercase()
).Other changes (functions copied from char):
to_digit
functionis_digit_radix
functionQuestions (I didn't know where to ask, so I write them here)
Copy
forAscii
? It sounds reasonable since it is just au8
.to_ascii
(which fails if the character is not ascii) and replace it byto_ascii_opt
?Ascii
are also available forchar
. Maybe we should unify them in a trait. At this moment we have theChar
trait, but it has some functions specially meant for UTF8 likeis_XID_start
andis_XID_continue
. Maybe we should split this trait in two:Char
andUtf8Char
.&[Ascii]
andVec<Ascii>
which offer conversion to normal strings or bytes). I would like to implement anAsciiString
to bring order to this. Should I just do it and open a PR?[breaking-change]