about summary refs log tree commit diff
diff options
context:
space:
mode:
authorteor <teor@riseup.net>2025-05-12 18:49:36 +1000
committerteor <teor@riseup.net>2025-05-15 07:58:30 +1000
commit8f0522dc811b7132c3bd2b2bc5c134a869824cf3 (patch)
treeef0d7d88e5e49353991bb285dcf6ba1babb217e6
parentac9ac0e0f36dcd7f8a8f0405cd003585fe4e4426 (diff)
downloadrust-8f0522dc811b7132c3bd2b2bc5c134a869824cf3.tar.gz
rust-8f0522dc811b7132c3bd2b2bc5c134a869824cf3.zip
Fix confusing WTF surrogate safety docs
-rw-r--r--library/std/src/ffi/os_str.rs6
-rw-r--r--library/std/src/sys/os_str/wtf8.rs6
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 72bdf03ee61..7f0033c1962 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);