-
-
Notifications
You must be signed in to change notification settings - Fork 14.3k
Implement TryFrom<char> for usize.
#146792
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
|
Failed to set assignee to
|
|
r? @ibraheemdev rustbot has assigned @ibraheemdev. Use |
|
@rustbot label +T-libs-api -T-libs needs-fcp r? libs-api |
This comment has been minimized.
This comment has been minimized.
226e29a to
23ae20b
Compare
This comment has been minimized.
This comment has been minimized.
23ae20b to
cb66ec2
Compare
This comment has been minimized.
This comment has been minimized.
cb66ec2 to
306fad6
Compare
This comment has been minimized.
This comment has been minimized.
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.
Thanks!
|
@rfcbot fcp merge |
|
Team member @dtolnay has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), 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. |
|
🔔 This is now entering its final comment period, as per the review above. 🔔 |
|
The final comment period, with a disposition to merge, as per the review above, is now complete. As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed. |
library/core/src/char/convert.rs
Outdated
| /// `usize`. | ||
| /// | ||
| /// Generally speaking, this conversion can be seen as obtaining the character's corresponding | ||
| /// UTF-32 code point to the extent representable by pointers addresses. |
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.
Grammar nitpick:
| /// UTF-32 code point to the extent representable by pointers addresses. | |
| /// UTF-32 code point to the extent representable by pointer addresses. |
But it might be even better to use the same wording as the usize definition:
| /// UTF-32 code point to the extent representable by pointers addresses. | |
| /// UTF-32 code point to the extent representable by pointer-sized integers. |
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.
"Pointer-sized integers" is a bit ambiguous, e.g. any pointer type with non-ZST metadata will be larger than usize.
306fad6 to
cb5f95c
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
Sorry for the delay, this PR should be mergeable now. FCP has long passed. @rustbot label -needs-fcp |
|
Can this be backported to 1.93.0 (still in beta), given that the FCP passed before the branch? |
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.
Thank you.
Regarding a beta backport:
- The FCP completion date is not a factor that I know of us having used to justify any previous library API backport, or if it has happened, it is not routine.
- We are into the 3rd week of the 6 week release cycle so it is getting to be late to backport anything other than bugfixes.
- For most purposes this feature is a minor usability improvement of writing
usize::try_from(ch)instead ofusize::try_from(u32::from(ch)). For a backport I would want to ascertain what makes this feature (relative to the typical other things landing in nightly this week) something that users would want to use as soon as possible.
|
@bors r+ |
Rollup merge of #146792 - bjoernager:usize-try-from-char, r=dtolnay Implement `TryFrom<char>` for `usize`. Feature gate: `usize_try_from_char`. This PR implements `TryFrom<char>` for `usize`. `usize` is currently the only, unsigned, integral type to not implement `TryFrom<char>`. Technically, this conversion is trivial and can already be expressed with some indirection. I think it useful to be able to describe this set of types with this interface.
Feature gate:
usize_try_from_char.This PR implements
TryFrom<char>forusize.usizeis currently the only, unsigned, integral type to not implementTryFrom<char>. Technically, this conversion is trivial and can already be expressed with some indirection.I think it useful to be able to describe this set of types with this interface.