I found the OsStr(ing) documentation misleading w.r.t. Windows #53261
Labels
A-docs
Area: documentation for any part of the project, including the compiler, standard library, and tools
A-FFI
Area: Foreign function interface (FFI)
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
O-windows
Operating system: Windows
P-medium
Medium priority
T-libs-api
Relevant to the library API team, which will review and decide on the PR/issue.
The documentation for
std::ffi::OsString
says—The documentation for
std::ffi
§ "Representations of non-Rust strings" says—These statements led me to understand that—
OsString
would represent its text as "arbitrary sequences of non-zero 16-bit values", and not as UTF-8, and thusOsStr
would reference such a non-UTF-8 sequence, and thusOsStr::to_str
— which returns anOption
al&str
that (by my imperfect understanding of Rust reference rules) would have to reference the same thing as theOsStr
— almost always would returnNone
on Windows (except for, e.g., empty strings), because a Windows string could not validly be read as a Ruststr
.However, @retep998 tells me that—
OsString
stores its text in WTF-8 on Windows, andWas my misinterpretation of the documentation unreasonable? If not, could the documentation be clarified on this point?
The text was updated successfully, but these errors were encountered: