diff options
| author | Jacob Pratt <jacob@jhpratt.dev> | 2025-05-26 03:38:17 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-26 03:38:17 +0200 |
| commit | 9aae60befc0ebafa21233827d7046187a0396a3d (patch) | |
| tree | 78aebad1fdc5c58afcc096ac205f47a4b4f00fc1 | |
| parent | 6257d2fb1c8f673b1abb20d155bac80a2a80937c (diff) | |
| parent | 8f0522dc811b7132c3bd2b2bc5c134a869824cf3 (diff) | |
| download | rust-9aae60befc0ebafa21233827d7046187a0396a3d.tar.gz rust-9aae60befc0ebafa21233827d7046187a0396a3d.zip | |
Rollup merge of #140936 - teor2345:wtf-surrogate-docs, r=workingjubilee
Clarify WTF-8 safety docs This PR is a follow-up to PR #140159, which clarifies ~~two things~~: - the WTF-8 safety comment [was confusing](https://github.com/rust-lang/rust/pull/140159#discussion_r2082766965), 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``
| -rw-r--r-- | library/std/src/ffi/os_str.rs | 6 | ||||
| -rw-r--r-- | library/std/src/sys/os_str/wtf8.rs | 6 |
2 files changed, 6 insertions, 6 deletions
diff --git a/library/std/src/ffi/os_str.rs b/library/std/src/ffi/os_str.rs index ead48775127..b0580b467be 100644 --- a/library/std/src/ffi/os_str.rs +++ b/library/std/src/ffi/os_str.rs @@ -594,9 +594,9 @@ impl OsString { /// The slice must be valid for the platform encoding (as described in /// [`OsStr::from_encoded_bytes_unchecked`]). /// - /// This bypasses the encoding-dependent surrogate joining, so `self` must - /// not end with a leading surrogate half and `other` must not start with - /// with a trailing surrogate half. + /// This bypasses the encoding-dependent surrogate joining, so either + /// `self` must not end with a leading surrogate half, or `other` must not + /// start with a trailing surrogate half. #[inline] pub(crate) unsafe fn extend_from_slice_unchecked(&mut self, other: &[u8]) { // SAFETY: Guaranteed by caller. diff --git a/library/std/src/sys/os_str/wtf8.rs b/library/std/src/sys/os_str/wtf8.rs index 5174ea65d0c..892bd2e3de6 100644 --- a/library/std/src/sys/os_str/wtf8.rs +++ b/library/std/src/sys/os_str/wtf8.rs @@ -215,9 +215,9 @@ impl Buf { /// The slice must be valid for the platform encoding (as described in /// [`Slice::from_encoded_bytes_unchecked`]). /// - /// This bypasses the WTF-8 surrogate joining, so `self` must not end with a - /// leading surrogate half and `other` must not start with with a trailing - /// surrogate half. + /// This bypasses the WTF-8 surrogate joining, so either `self` must not + /// end with a leading surrogate half, or `other` must not start with a + /// trailing surrogate half. #[inline] pub unsafe fn extend_from_slice_unchecked(&mut self, other: &[u8]) { self.inner.extend_from_slice(other); |
