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 CStr are valid UTF-8 data, this function will return a Cow::Borrowed(&str) with the corresponding &str slice. Otherwise, it will replace any invalid UTF-8 sequences with U+FFFD REPLACEMENT CHARACTER and return a Cow::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.
Location
https://doc.rust-lang.org/stable/std/ffi/struct.CStr.html#method.to_str
Summary
The documentation for the
to_string_lossy()method ofCStr, which returns aCow<'_, str>, currently contains the following text:The owned case seems wrong. I believe that it would return a
Cow::Owned(String)not aCow::Owned(&str).The documentation did actually claim
Cow::Owned(String)was returned prior to commit 67065fe which changed it to the above without explanation.