about summary refs log tree commit diff
path: root/library/std/src/sys
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2024-04-26 17:55:10 +0200
committerRalf Jung <post@ralfj.de>2024-04-26 18:09:09 +0200
commitc47978a241ac1dd512b2ed7d146c1e1a71326dec (patch)
tree758a75d2684f9848c9078fbdefc9f2ae71e0f8c8 /library/std/src/sys
parent5ff8fbb2d83d423974d21d754b5ee56a4c869551 (diff)
downloadrust-c47978a241ac1dd512b2ed7d146c1e1a71326dec.tar.gz
rust-c47978a241ac1dd512b2ed7d146c1e1a71326dec.zip
PathBuf: replace transmuting by accessor functions
Diffstat (limited to 'library/std/src/sys')
-rw-r--r--library/std/src/sys/os_str/bytes.rs6
-rw-r--r--library/std/src/sys/os_str/wtf8.rs6
2 files changed, 12 insertions, 0 deletions
diff --git a/library/std/src/sys/os_str/bytes.rs b/library/std/src/sys/os_str/bytes.rs
index 4ca3f1cd185..3076e18b237 100644
--- a/library/std/src/sys/os_str/bytes.rs
+++ b/library/std/src/sys/os_str/bytes.rs
@@ -198,6 +198,12 @@ impl Buf {
     pub fn into_rc(&self) -> Rc<Slice> {
         self.as_slice().into_rc()
     }
+
+    /// Part of a hack to make PathBuf::push/pop more efficient.
+    #[inline]
+    pub(crate) fn as_mut_vec_for_path_buf(&mut self) -> &mut Vec<u8> {
+        &mut self.inner
+    }
 }
 
 impl Slice {
diff --git a/library/std/src/sys/os_str/wtf8.rs b/library/std/src/sys/os_str/wtf8.rs
index 352bd735903..b3ceb55802d 100644
--- a/library/std/src/sys/os_str/wtf8.rs
+++ b/library/std/src/sys/os_str/wtf8.rs
@@ -158,6 +158,12 @@ impl Buf {
     pub fn into_rc(&self) -> Rc<Slice> {
         self.as_slice().into_rc()
     }
+
+    /// Part of a hack to make PathBuf::push/pop more efficient.
+    #[inline]
+    pub(crate) fn as_mut_vec_for_path_buf(&mut self) -> &mut Vec<u8> {
+        self.inner.as_mut_vec_for_path_buf()
+    }
 }
 
 impl Slice {