Skip to content

OsString::into_encoded_bytes points to wrong from_encoded_bytes_unchecked for round trip #133010

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
lolbinarycat opened this issue Nov 13, 2024 · 0 comments · Fixed by #135821
Closed
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

Location

https://doc.rust-lang.org/stable/std/ffi/struct.OsString.html#method.into_encoded_bytes

Summary

contains this line:

To convert the byte slice back into an OsString, use the OsStr::from_encoded_bytes_unchecked function

however, if you want a proper round trip, you need to use OsString::from_encoded_bytes_unchecked, which actually consumes the Vec instead of taking a byte slice.

@lolbinarycat lolbinarycat added the A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools label Nov 13, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Nov 13, 2024
@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 Nov 13, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jan 21, 2025
fix OsString::from_encoded_bytes_unchecked description

fixes rust-lang#133010
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jan 21, 2025
fix OsString::from_encoded_bytes_unchecked description

fixes rust-lang#133010
@bors bors closed this as completed in 50c89b6 Jan 22, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Jan 22, 2025
Rollup merge of rust-lang#135821 - hkBst:patch-11, r=ibraheemdev

fix OsString::from_encoded_bytes_unchecked description

fixes rust-lang#133010
github-actions bot pushed a commit to tautschnig/verify-rust-std that referenced this issue Mar 11, 2025
fix OsString::from_encoded_bytes_unchecked description

fixes rust-lang#133010
# for free to join this conversation on GitHub. Already have an account? # 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
Development

Successfully merging a pull request may close this issue.

3 participants