about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2024-09-06 07:33:57 +0200
committerGitHub <noreply@github.com>2024-09-06 07:33:57 +0200
commit45d6957f241ee48fe1a149a91d9c9f7f6d7aae4f (patch)
tree6a7c5a84e465e1ceebafac5d0365600fe3cdb49b
parentb09f3160582c7a2d5e07bc37999925df721bbbbb (diff)
parent49a93df77d3c617e14fd466f30d06b4ab54a64df (diff)
downloadrust-45d6957f241ee48fe1a149a91d9c9f7f6d7aae4f.tar.gz
rust-45d6957f241ee48fe1a149a91d9c9f7f6d7aae4f.zip
Rollup merge of #129963 - rjooske:fix/inaccurate_to_string_lossy_doc, r=workingjubilee
Inaccurate `{Path,OsStr}::to_string_lossy()` documentation

The documentation of `Path::to_string_lossy()` and `OsStr::to_string_lossy()` says the following:
> Any non-Unicode sequences are replaced with `U+FFFD REPLACEMENT CHARACTER`

which didn't immediately make sense to me. ("non-Unicode sequences"?)
Since both `to_string_lossy` functions eventually become just a call to `String::from_utf8_lossy`, I believe the documentation meant to say:
> Any *non-UTF-8* sequences are replaced with `U+FFFD REPLACEMENT CHARACTER`

This PR corrects this mistake in the documentation.

For the record, a similar quote can be found in the documentation of `String::from_utf8_lossy`:
> ... During this conversion, `from_utf8_lossy()` will replace any invalid UTF-8 sequences with `U+FFFD REPLACEMENT CHARACTER`, ...
-rw-r--r--library/std/src/ffi/os_str.rs2
-rw-r--r--library/std/src/path.rs2
2 files changed, 2 insertions, 2 deletions
diff --git a/library/std/src/ffi/os_str.rs b/library/std/src/ffi/os_str.rs
index 918eec2d0d8..99bea676e12 100644
--- a/library/std/src/ffi/os_str.rs
+++ b/library/std/src/ffi/os_str.rs
@@ -852,7 +852,7 @@ impl OsStr {
 
     /// Converts an `OsStr` to a <code>[Cow]<[str]></code>.
     ///
-    /// Any non-Unicode sequences are replaced with
+    /// Any non-UTF-8 sequences are replaced with
     /// [`U+FFFD REPLACEMENT CHARACTER`][U+FFFD].
     ///
     /// [U+FFFD]: crate::char::REPLACEMENT_CHARACTER
diff --git a/library/std/src/path.rs b/library/std/src/path.rs
index 9eaa0e01c2c..506ad445b6b 100644
--- a/library/std/src/path.rs
+++ b/library/std/src/path.rs
@@ -2200,7 +2200,7 @@ impl Path {
 
     /// Converts a `Path` to a [`Cow<str>`].
     ///
-    /// Any non-Unicode sequences are replaced with
+    /// Any non-UTF-8 sequences are replaced with
     /// [`U+FFFD REPLACEMENT CHARACTER`][U+FFFD].
     ///
     /// [U+FFFD]: super::char::REPLACEMENT_CHARACTER