-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Closed
Labels
A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsArea: Documentation for any part of the project, including the compiler, standard library, and toolsT-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.
Description
Location
https://doc.rust-lang.org/stable/std/ffi/struct.CStr.html#method.to_str
Summary
The documentation for the to_string_lossy() method of CStr, which returns a Cow<'_, str>, currently contains the following text:
If the contents of the
CStrare valid UTF-8 data, this function will return aCow::Borrowed(&str)with the corresponding&strslice. Otherwise, it will replace any invalid UTF-8 sequences withU+FFFD REPLACEMENT CHARACTERand return aCow::Owned(&str)with the result.
The owned case seems wrong. I believe that it would return a Cow::Owned(String) not a Cow::Owned(&str).
The documentation did actually claim Cow::Owned(String) was returned prior to commit 67065fe which changed it to the above without explanation.
Metadata
Metadata
Assignees
Labels
A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsArea: Documentation for any part of the project, including the compiler, standard library, and toolsT-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.