You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
jnqnfe opened this issue
Apr 15, 2025
· 1 comment
· Fixed by #139922
Labels
A-docsArea: 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.
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.
The text was updated successfully, but these errors were encountered:
jnqnfe
added
the
A-docs
Area: Documentation for any part of the project, including the compiler, standard library, and tools
label
Apr 15, 2025
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
Apr 15, 2025
fix incorrect type in cstr `to_string_lossy()` docs
Restoring what it said prior to commit 67065fe in which it was changed incorrectly with no supporting explanation.
Closesrust-lang#139835.
fix incorrect type in cstr `to_string_lossy()` docs
Restoring what it said prior to commit 67065fe in which it was changed incorrectly with no supporting explanation.
Closesrust-lang#139835.
Rollup merge of rust-lang#139922 - jnqnfe:cstr_doc_fix, r=jhpratt
fix incorrect type in cstr `to_string_lossy()` docs
Restoring what it said prior to commit 67065fe in which it was changed incorrectly with no supporting explanation.
Closesrust-lang#139835.
A-docsArea: 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.
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.The text was updated successfully, but these errors were encountered: