about summary refs log tree commit diff
path: root/library/std/src/sys
diff options
context:
space:
mode:
authorash <97464181+Borgerr@users.noreply.github.com>2024-06-25 07:34:35 -0600
committerash <97464181+Borgerr@users.noreply.github.com>2024-06-25 07:36:34 -0600
commitaa46a3368eb017eba41bfab956c7787d46c09935 (patch)
treed35402a118f084f15479a264ddbdf393deae819b /library/std/src/sys
parent7e187e8e4b0a12b9adc0d24dc30dffde6ceaba4a (diff)
downloadrust-aa46a3368eb017eba41bfab956c7787d46c09935.tar.gz
rust-aa46a3368eb017eba41bfab956c7787d46c09935.zip
`PathBuf::as_mut_vec` removed and verified for UEFI and Windows platforms #126333
Diffstat (limited to 'library/std/src/sys')
-rw-r--r--library/std/src/sys/os_str/bytes.rs15
-rw-r--r--library/std/src/sys/os_str/wtf8.rs16
2 files changed, 23 insertions, 8 deletions
diff --git a/library/std/src/sys/os_str/bytes.rs b/library/std/src/sys/os_str/bytes.rs
index e494f7d1dea..2a7477e3afc 100644
--- a/library/std/src/sys/os_str/bytes.rs
+++ b/library/std/src/sys/os_str/bytes.rs
@@ -202,15 +202,20 @@ impl Buf {
         self.as_slice().into_rc()
     }
 
-    /// Part of a hack to make PathBuf::push/pop more efficient.
+    /// Provides plumbing to core `Vec::truncate`.
+    /// More well behaving alternative to allowing outer types
+    /// full mutable access to the core `Vec`.
     #[inline]
-    pub(crate) fn as_mut_vec_for_path_buf(&mut self) -> &mut Vec<u8> {
-        &mut self.inner
+    pub(crate) fn truncate(&mut self, len: usize) {
+        self.inner.truncate(len);
     }
 
+    /// Provides plumbing to core `Vec::extend_from_slice`.
+    /// More well behaving alternative to allowing outer types
+    /// full mutable access to the core `Vec`.
     #[inline]
-    pub(crate) fn truncate(&mut self, len: usize) {
-        self.inner.truncate(len);
+    pub(crate) fn extend_from_slice(&mut self, other: &[u8]) {
+        self.inner.extend_from_slice(other);
     }
 }
 
diff --git a/library/std/src/sys/os_str/wtf8.rs b/library/std/src/sys/os_str/wtf8.rs
index 96690f8c44e..edb923a4750 100644
--- a/library/std/src/sys/os_str/wtf8.rs
+++ b/library/std/src/sys/os_str/wtf8.rs
@@ -165,10 +165,20 @@ impl Buf {
         self.as_slice().into_rc()
     }
 
-    /// Part of a hack to make PathBuf::push/pop more efficient.
+    /// Provides plumbing to core `Vec::truncate`.
+    /// More well behaving alternative to allowing outer types
+    /// full mutable access to the core `Vec`.
     #[inline]
-    pub(crate) fn as_mut_vec_for_path_buf(&mut self) -> &mut Vec<u8> {
-        self.inner.as_mut_vec_for_path_buf()
+    pub(crate) fn truncate(&mut self, len: usize) {
+        self.inner.truncate(len);
+    }
+
+    /// Provides plumbing to core `Vec::extend_from_slice`.
+    /// More well behaving alternative to allowing outer types
+    /// full mutable access to the core `Vec`.
+    #[inline]
+    pub(crate) fn extend_from_slice(&mut self, other: &[u8]) {
+        self.inner.extend_from_slice(other);
     }
 }