diff options
| author | Corey Farwell <coreyf@rwell.org> | 2017-09-14 22:32:52 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-09-14 22:32:52 -0400 |
| commit | 68e0f28304249a4f2db6b177b3be156ba4774a92 (patch) | |
| tree | 78839e9a358a6781af8c1dd0a21b3f9503382b3a | |
| parent | 2a86884a37e735c3ba7066c0f1c0744415fb2d31 (diff) | |
| parent | 258ef37f8e81388a11f420411e35b427215b0754 (diff) | |
| download | rust-68e0f28304249a4f2db6b177b3be156ba4774a92.tar.gz rust-68e0f28304249a4f2db6b177b3be156ba4774a92.zip | |
Rollup merge of #44572 - frewsxcv:frewsxcv-from-utf16-lossy, r=QuietMisdreavus
Clarify return type of `String::from_utf16_lossy`. Fixes https://github.com/rust-lang/rust/issues/32874
| -rw-r--r-- | src/liballoc/string.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/liballoc/string.rs b/src/liballoc/string.rs index 8cecc59127e..46b96df1eab 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: |
