-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
"only u8
can be cast as char
, not i32
" needs further information
#91836
Comments
u8
can be cast as char
, not i32
" is confusingu8
can be cast as char
, not i32
" needs further information
I think a good improvement would be to @GKFX are you interested in working on one or both of those? :) |
@rustbot claim |
While I was reading the docs I noticed a minor error in
This isn't true; a USV is a Code Point within either of two ranges, not one. It's also a bit cagey about what the ranges are numerically; I don't know if this is intentional. Personally I would re-write it to the below:
Would I put that in the same PR (as they're both |
@GKFX A new PR would be better. |
Clarify documentation on char::MAX As mentioned in rust-lang#91836 (comment), the documentation on `char::MAX` is not quite correct – USVs are not "only ones within a certain range", they are code points _outside_ a certain range. I have corrected this and given the actual numbers as there is no reason to hide them.
Clarify error on casting larger integers to char Closes rust-lang#91836 with changes to E0604.md and a `span_help`.
Given the following code: link
The current output is:
This is not very clear. There are two pieces of background information the user needs here:
char
s are Unicode scalar values, which are any integer value from 0 to 0xD7FF and 0xE000 to 0x10FFFF. Only u8 can be statically guaranteed to meet this requirement so only u8 can be cast to char.The user is directed to further information available at
rustc --explain E0604
and https://doc.rust-lang.org/reference/expressions/operator-expr.html#type-cast-expressions, neither of which explains either of those two points.The text was updated successfully, but these errors were encountered: