about summary refs log tree commit diff
diff options
context:
space:
mode:
authorCorey Farwell <coreyf@rwell.org>2017-09-14 15:34:31 -0400
committerCorey Farwell <coreyf@rwell.org>2017-09-14 15:47:37 -0400
commit258ef37f8e81388a11f420411e35b427215b0754 (patch)
treed8df57235ff301529c46cf35f60a9893a0395902
parent5dfc84cfa72b405c194228b53c4de3f6474204ec (diff)
downloadrust-258ef37f8e81388a11f420411e35b427215b0754.tar.gz
rust-258ef37f8e81388a11f420411e35b427215b0754.zip
Clarify return type of `String::from_utf16_lossy`.
Fixes https://github.com/rust-lang/rust/issues/32874
-rw-r--r--src/liballoc/string.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/liballoc/string.rs b/src/liballoc/string.rs
index 1708f3e3987..088082c261a 100644
--- a/src/liballoc/string.rs
+++ b/src/liballoc/string.rs
@@ -622,6 +622,13 @@ impl String {
     /// Decode a UTF-16 encoded slice `v` into a `String`, replacing
     /// invalid data with the replacement character (U+FFFD).
     ///
+    /// Unlike [`from_utf8_lossy`] which returns a [`Cow<'a, str>`],
+    /// `from_utf16_lossy` returns a `String` since the UTF-16 to UTF-8
+    /// conversion requires a memory allocation.
+    ///
+    /// [`from_utf8_lossy`]: #method.from_utf8_lossy
+    /// [`Cow<'a, str>`]: ../borrow/enum.Cow.html
+    ///
     /// # Examples
     ///
     /// Basic usage: