Skip to content

Conversation

@bjoernager
Copy link
Contributor

@bjoernager bjoernager commented Sep 19, 2025

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.

@rustbot
Copy link
Collaborator

rustbot commented Sep 19, 2025

Failed to set assignee to ibraheemdev: cannot assign: error sending request

Note: Only org members with at least the repository "read" role, users with write permissions, or people who have commented on the PR may be assigned.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Sep 19, 2025
@rustbot
Copy link
Collaborator

rustbot commented Sep 19, 2025

r? @ibraheemdev

rustbot has assigned @ibraheemdev.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@bjoernager
Copy link
Contributor Author

bjoernager commented Sep 19, 2025

@rustbot label +T-libs-api -T-libs needs-fcp

r? libs-api

@rustbot rustbot added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. and removed T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Sep 19, 2025
@rustbot rustbot assigned dtolnay and unassigned ibraheemdev Sep 19, 2025
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rustbot rustbot added the needs-fcp This change is insta-stable, or significant enough to need a team FCP to proceed. label Sep 21, 2025
@bjoernager

This comment has been minimized.

Copy link
Member

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dtolnay
Copy link
Member

dtolnay commented Oct 8, 2025

@rfcbot fcp merge

@rust-rfcbot
Copy link
Collaborator

rust-rfcbot commented Oct 8, 2025

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.

@rust-rfcbot rust-rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. labels Oct 8, 2025
@rust-rfcbot rust-rfcbot added final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. and removed proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. labels Nov 20, 2025
@rust-rfcbot
Copy link
Collaborator

🔔 This is now entering its final comment period, as per the review above. 🔔

@rust-rfcbot rust-rfcbot added finished-final-comment-period The final comment period is finished for this PR / Issue. to-announce Announce this issue on triage meeting and removed final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. labels Nov 30, 2025
@rust-rfcbot
Copy link
Collaborator

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.

/// `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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grammar nitpick:

Suggested change
/// 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:

Suggested change
/// UTF-32 code point to the extent representable by pointers addresses.
/// UTF-32 code point to the extent representable by pointer-sized integers.

Copy link
Contributor Author

@bjoernager bjoernager Dec 29, 2025

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.

@rustbot
Copy link
Collaborator

rustbot commented Dec 29, 2025

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.

@bjoernager
Copy link
Contributor Author

Sorry for the delay, this PR should be mergeable now. FCP has long passed.

@rustbot label -needs-fcp

@rustbot rustbot removed the needs-fcp This change is insta-stable, or significant enough to need a team FCP to proceed. label Dec 29, 2025
@bjoernager
Copy link
Contributor Author

bjoernager commented Dec 29, 2025

Can this be backported to 1.93.0 (still in beta), given that the FCP passed before the branch?

Copy link
Member

@dtolnay dtolnay left a 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:

  1. 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.
  2. 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.
  3. For most purposes this feature is a minor usability improvement of writing usize::try_from(ch) instead of usize::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.

View changes since this review

@dtolnay
Copy link
Member

dtolnay commented Dec 30, 2025

@bors r+

@bors
Copy link
Collaborator

bors commented Dec 30, 2025

📌 Commit cb5f95c has been approved by dtolnay

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 30, 2025
bors added a commit that referenced this pull request Dec 30, 2025
Rollup of 3 pull requests

Successful merges:

 - #146792 (Implement `TryFrom<char>` for `usize`.)
 - #150484 (Mark set_times as unavailable for RTEMS target)
 - #150498 (mir_build: Remove several remnants of `#![feature(inline_const_pat)]`)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 09baabc into rust-lang:main Dec 30, 2025
11 checks passed
@rustbot rustbot added this to the 1.94.0 milestone Dec 30, 2025
rust-timer added a commit that referenced this pull request Dec 30, 2025
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. finished-final-comment-period The final comment period is finished for this PR / Issue. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. to-announce Announce this issue on triage meeting

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants