Skip to content

Commit 258ef37

Browse files
committed
Clarify return type of String::from_utf16_lossy.
Fixes #32874
1 parent 5dfc84c commit 258ef37

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/liballoc/string.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,13 @@ impl String {
622622
/// Decode a UTF-16 encoded slice `v` into a `String`, replacing
623623
/// invalid data with the replacement character (U+FFFD).
624624
///
625+
/// Unlike [`from_utf8_lossy`] which returns a [`Cow<'a, str>`],
626+
/// `from_utf16_lossy` returns a `String` since the UTF-16 to UTF-8
627+
/// conversion requires a memory allocation.
628+
///
629+
/// [`from_utf8_lossy`]: #method.from_utf8_lossy
630+
/// [`Cow<'a, str>`]: ../borrow/enum.Cow.html
631+
///
625632
/// # Examples
626633
///
627634
/// Basic usage:

0 commit comments

Comments
 (0)