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
This commit is contained in:
Corey Farwell 2017-09-14 22:32:52 -04:00 committed by GitHub
commit 68e0f28304
1 changed files with 7 additions and 0 deletions

View File

@ -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: