Skip to content

Rollup of 7 pull requests #136448

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Feb 2, 2025
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions library/alloc/src/string.rs
Original file line number Diff line number Diff line change
@@ -712,8 +712,8 @@ impl String {
}
}

/// Decode a UTF-16–encoded vector `v` into a `String`, returning [`Err`]
/// if `v` contains any invalid data.
/// Decode a native endian UTF-16–encoded vector `v` into a `String`,
/// returning [`Err`] if `v` contains any invalid data.
///
/// # Examples
///
@@ -745,8 +745,8 @@ impl String {
Ok(ret)
}

/// Decode a UTF-16–encoded slice `v` into a `String`, replacing
/// invalid data with [the replacement character (`U+FFFD`)][U+FFFD].
/// Decode a native endian UTF-16–encoded slice `v` into a `String`,
/// replacing invalid data with [the replacement character (`U+FFFD`)][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
@@ -777,8 +777,8 @@ impl String {
.collect()
}

/// Decode a UTF-16LE–encoded vector `v` into a `String`, returning [`Err`]
/// if `v` contains any invalid data.
/// Decode a UTF-16LE–encoded vector `v` into a `String`,
/// returning [`Err`] if `v` contains any invalid data.
///
/// # Examples
///
@@ -852,8 +852,8 @@ impl String {
}
}

/// Decode a UTF-16BE–encoded vector `v` into a `String`, returning [`Err`]
/// if `v` contains any invalid data.
/// Decode a UTF-16BE–encoded vector `v` into a `String`,
/// returning [`Err`] if `v` contains any invalid data.
///
/// # Examples
///
6 changes: 3 additions & 3 deletions library/core/src/char/methods.rs
Original file line number Diff line number Diff line change
@@ -92,7 +92,7 @@ impl char {
#[stable(feature = "assoc_char_consts", since = "1.52.0")]
pub const UNICODE_VERSION: (u8, u8, u8) = crate::unicode::UNICODE_VERSION;

/// Creates an iterator over the UTF-16 encoded code points in `iter`,
/// Creates an iterator over the native endian UTF-16 encoded code points in `iter`,
/// returning unpaired surrogates as `Err`s.
///
/// # Examples
@@ -704,7 +704,7 @@ impl char {
unsafe { from_utf8_unchecked_mut(encode_utf8_raw(self as u32, dst)) }
}

/// Encodes this character as UTF-16 into the provided `u16` buffer,
/// Encodes this character as native endian UTF-16 into the provided `u16` buffer,
/// and then returns the subslice of the buffer that contains the encoded character.
///
/// # Panics
@@ -1828,7 +1828,7 @@ pub const fn encode_utf8_raw(code: u32, dst: &mut [u8]) -> &mut [u8] {
unsafe { slice::from_raw_parts_mut(dst.as_mut_ptr(), len) }
}

/// Encodes a raw `u32` value as UTF-16 into the provided `u16` buffer,
/// Encodes a raw `u32` value as native endian UTF-16 into the provided `u16` buffer,
/// and then returns the subslice of the buffer that contains the encoded character.
///
/// Unlike `char::encode_utf16`, this method also handles codepoints in the surrogate range.
3 changes: 2 additions & 1 deletion library/core/src/str/mod.rs
Original file line number Diff line number Diff line change
@@ -1108,7 +1108,8 @@ impl str {
LinesAny(self.lines())
}

/// Returns an iterator of `u16` over the string encoded as UTF-16.
/// Returns an iterator of `u16` over the string encoded
/// as native endian UTF-16 (without byte-order mark).
///
/// # Examples
///