Skip to content

feat: Add NonZero::<T>::from_str_radix#151945

Merged
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
sorairolake:feature/nonzero-from-str-radix
Feb 6, 2026
Merged

feat: Add NonZero::<T>::from_str_radix#151945
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
sorairolake:feature/nonzero-from-str-radix

Conversation

@sorairolake
Copy link
Contributor

@sorairolake sorairolake commented Feb 1, 2026

This pull request adds a method to NonZero<T> that parses a non-zero integer from a string slice with digits in a given base.

When using the combination of int::from_str_radix and NonZero::<T>::new, IntErrorKind::Zero cannot be returned as an error. When using NonZero::<T>::from_str, IntErrorKind::Zero can be returned as an error, but this method cannot parse non-decimal integers.

NonZero::<T>::from_str_radix can return IntErrorKind::Zero as an error, and can parse both decimal integers and non-decimal integers.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Feb 1, 2026
@sorairolake
Copy link
Contributor Author

@rustbot label +T-libs-api -T-libs
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 Feb 1, 2026
@sorairolake sorairolake force-pushed the feature/nonzero-from-str-radix branch from 2ca5c91 to 104eae1 Compare February 5, 2026 23:41
@sorairolake sorairolake marked this pull request as ready for review February 5, 2026 23:46
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 5, 2026
@rust-log-analyzer

This comment has been minimized.

@sorairolake sorairolake force-pushed the feature/nonzero-from-str-radix branch from 104eae1 to d0aa337 Compare February 6, 2026 07:16
@rustbot
Copy link
Collaborator

rustbot commented Feb 6, 2026

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.

@Amanieu
Copy link
Member

Amanieu commented Feb 6, 2026

@bors r+

@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 6, 2026

📌 Commit d0aa337 has been approved by Amanieu

It is now in the queue for this repository.

@rust-bors rust-bors bot 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 Feb 6, 2026
TaKO8Ki added a commit to TaKO8Ki/rust that referenced this pull request Feb 6, 2026
…tr-radix, r=Amanieu

feat: Add `NonZero::<T>::from_str_radix`

- Accepted ACP: rust-lang/libs-team#548
- Tracking issue: rust-lang#152193

This pull request adds a method to `NonZero<T>` that parses a non-zero integer from a string slice with digits in a given base.

When using the combination of `int::from_str_radix` and `NonZero::<T>::new`, [`IntErrorKind::Zero`](https://doc.rust-lang.org/core/num/enum.IntErrorKind.html#variant.Zero) cannot be returned as an error. When using `NonZero::<T>::from_str`, `IntErrorKind::Zero` can be returned as an error, but this method cannot parse non-decimal integers.

`NonZero::<T>::from_str_radix` can return `IntErrorKind::Zero` as an error, and can parse both decimal integers and non-decimal integers.
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Feb 6, 2026
…tr-radix, r=Amanieu

feat: Add `NonZero::<T>::from_str_radix`

- Accepted ACP: rust-lang/libs-team#548
- Tracking issue: rust-lang#152193

This pull request adds a method to `NonZero<T>` that parses a non-zero integer from a string slice with digits in a given base.

When using the combination of `int::from_str_radix` and `NonZero::<T>::new`, [`IntErrorKind::Zero`](https://doc.rust-lang.org/core/num/enum.IntErrorKind.html#variant.Zero) cannot be returned as an error. When using `NonZero::<T>::from_str`, `IntErrorKind::Zero` can be returned as an error, but this method cannot parse non-decimal integers.

`NonZero::<T>::from_str_radix` can return `IntErrorKind::Zero` as an error, and can parse both decimal integers and non-decimal integers.
rust-bors bot pushed a commit that referenced this pull request Feb 6, 2026
…uwer

Rollup of 6 pull requests

Successful merges:

 - #151590 (cmse: don't use `BackendRepr` when checking return type)
 - #151945 (feat: Add `NonZero::<T>::from_str_radix`)
 - #152000 (Fix ICE in normalizing inherent associated consts with `#[type_const]`)
 - #152192 (Always use Xcode-provided Clang in macOS CI)
 - #152196 (bootstrap: Remove `ShouldRun::paths`)
 - #152222 (Re-add TaKO8Ki to triagebot review queue)
@rust-bors rust-bors bot merged commit f509250 into rust-lang:main Feb 6, 2026
11 checks passed
@rustbot rustbot added this to the 1.95.0 milestone Feb 6, 2026
rust-timer added a commit that referenced this pull request Feb 6, 2026
Rollup merge of #151945 - sorairolake:feature/nonzero-from-str-radix, r=Amanieu

feat: Add `NonZero::<T>::from_str_radix`

- Accepted ACP: rust-lang/libs-team#548
- Tracking issue: #152193

This pull request adds a method to `NonZero<T>` that parses a non-zero integer from a string slice with digits in a given base.

When using the combination of `int::from_str_radix` and `NonZero::<T>::new`, [`IntErrorKind::Zero`](https://doc.rust-lang.org/core/num/enum.IntErrorKind.html#variant.Zero) cannot be returned as an error. When using `NonZero::<T>::from_str`, `IntErrorKind::Zero` can be returned as an error, but this method cannot parse non-decimal integers.

`NonZero::<T>::from_str_radix` can return `IntErrorKind::Zero` as an error, and can parse both decimal integers and non-decimal integers.
@sorairolake sorairolake deleted the feature/nonzero-from-str-radix branch February 7, 2026 03:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants