Skip to content

docs(num): clarify conditions under which error occurs in impl TryFrom<int> for int - #162076

Open
sorairolake wants to merge 1 commit into
rust-lang:mainfrom
sorairolake:clarify-int-try-from-docs
Open

docs(num): clarify conditions under which error occurs in impl TryFrom<int> for int#162076
sorairolake wants to merge 1 commit into
rust-lang:mainfrom
sorairolake:clarify-int-try-from-docs

Conversation

@sorairolake

@sorairolake sorairolake commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

impl_try_from_unbounded always returns Ok(T), but the documentation is written as if it may return an error, so I fixed this.

I also clarified that impl_try_from_lower_bounded returns an error only when the source value is less than T::MIN, and impl_try_from_upper_bounded returns an error only when the source value is greater than T::MAX.

While the original text

This returns an error if the source value is outside of the range of the target type.

is fine for both cases, but I think the revised text makes it clearer that the error occurs at either the lower bound or the upper bound.

As for impl_try_from_both_bounded, I think the current text is fine, so I have not made any changes to it.

@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 Aug 31, 2026
@rustbot

rustbot commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

r? @JohnTitor

rustbot has assigned @JohnTitor.
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

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: libs
  • libs expanded to 12 candidates
  • Random selection from JohnTitor, Mark-Simulacrum, clarfonthey, joboet, nia-e

@sorairolake

Copy link
Copy Markdown
Contributor Author

@rustbot label +A-docs

@rustbot rustbot added the A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools label Aug 31, 2026
@sorairolake sorairolake changed the title docs(num): clarify conditions under which error occurs docs(num): clarify conditions under which error occurs in impl TryFrom<int> for int Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants