Skip to content

Commit 905d011

Browse files
authored
Rollup merge of rust-lang#140936 - teor2345:wtf-surrogate-docs, r=workingjubilee
Clarify WTF-8 safety docs This PR is a follow-up to PR rust-lang#140159, which clarifies ~~two things~~: - the WTF-8 safety comment [was confusing](rust-lang#140159 (comment)), either surrogate condition is actually sufficient for safety, both are not required - ~~the private `os_str::Slice` type name is easily confused with `std::slice`~~ ~~Happy to bikeshed the `OsSlice` name, other alternatives are `OsStrSlice` and `StrSlice`. Now it's got a distinct name from `std::slice`, it's easy to search and replace.~~ cc `@thaliaarchi` `@workingjubilee`
2 parents 49add8e + 8f0522d commit 905d011

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

library/std/src/ffi/os_str.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -594,9 +594,9 @@ impl OsString {
594594
/// The slice must be valid for the platform encoding (as described in
595595
/// [`OsStr::from_encoded_bytes_unchecked`]).
596596
///
597-
/// This bypasses the encoding-dependent surrogate joining, so `self` must
598-
/// not end with a leading surrogate half and `other` must not start with
599-
/// with a trailing surrogate half.
597+
/// This bypasses the encoding-dependent surrogate joining, so either
598+
/// `self` must not end with a leading surrogate half, or `other` must not
599+
/// start with a trailing surrogate half.
600600
#[inline]
601601
pub(crate) unsafe fn extend_from_slice_unchecked(&mut self, other: &[u8]) {
602602
// SAFETY: Guaranteed by caller.

library/std/src/sys/os_str/wtf8.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,9 @@ impl Buf {
215215
/// The slice must be valid for the platform encoding (as described in
216216
/// [`Slice::from_encoded_bytes_unchecked`]).
217217
///
218-
/// This bypasses the WTF-8 surrogate joining, so `self` must not end with a
219-
/// leading surrogate half and `other` must not start with with a trailing
220-
/// surrogate half.
218+
/// This bypasses the WTF-8 surrogate joining, so either `self` must not
219+
/// end with a leading surrogate half, or `other` must not start with a
220+
/// trailing surrogate half.
221221
#[inline]
222222
pub unsafe fn extend_from_slice_unchecked(&mut self, other: &[u8]) {
223223
self.inner.extend_from_slice(other);

0 commit comments

Comments
 (0)