Skip to content

TryFrom and TryInto docs don't say that TryInto should be preferred in bounds. #140761

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

Closed
lolbinarycat opened this issue May 7, 2025 · 1 comment · Fixed by #140791
Closed
Assignees
Labels
A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools T-libs Relevant to the library team, which will review and decide on the PR/issue.

Comments

@lolbinarycat
Copy link
Contributor

lolbinarycat commented May 7, 2025

Location

https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html
https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html

Summary

both Into and From say that Into should be preferred in bounds and From should be preferred when implementing.

only the part about preferring TryFrom appears in the docs mentioned above.

this has led to some usages of TryFrom in bounds, such as in ureq::get.

@lolbinarycat lolbinarycat added the A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools label May 7, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label May 7, 2025
@xizheyin
Copy link
Contributor

xizheyin commented May 8, 2025

@rustbot claim

@jieyouxu jieyouxu added T-libs Relevant to the library team, which will review and decide on the PR/issue. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels May 14, 2025
hkBst added a commit to hkBst/rust that referenced this issue May 16, 2025
std: explain prefer `TryInto` over `TryFrom` when specifying traits bounds on generic function

Fixes rust-lang#140761

This PR keeps the explanations of `Into` and `From` consistent and adds explanations for `TryInto` and `TryFrom`.

r? libs
@bors bors closed this as completed in 315296b May 16, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this issue May 16, 2025
Rollup merge of rust-lang#140791 - xizheyin:issue-140761, r=ibraheemdev

std: explain prefer `TryInto` over `TryFrom` when specifying traits bounds on generic function

Fixes rust-lang#140761

This PR keeps the explanations of `Into` and `From` consistent and adds explanations for `TryInto` and `TryFrom`.

r? libs
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 T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
4 participants