Closed
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
CStr
are valid UTF-8 data, this function will return aCow::Borrowed(&str)
with the corresponding&str
slice. Otherwise, it will replace any invalid UTF-8 sequences withU+FFFD REPLACEMENT CHARACTER
and 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.