about summary refs log tree commit diff
path: root/library/std/src
diff options
context:
space:
mode:
authorash <97464181+Borgerr@users.noreply.github.com>2024-06-23 17:24:59 -0600
committerash <97464181+Borgerr@users.noreply.github.com>2024-06-25 07:36:34 -0600
commit7e187e8e4b0a12b9adc0d24dc30dffde6ceaba4a (patch)
tree8701ecc729426421afafa9ac27bc18aba50cf79f /library/std/src
parentb08cd69684e4b121399b3ea0f9ee6cc4a51cad07 (diff)
downloadrust-7e187e8e4b0a12b9adc0d24dc30dffde6ceaba4a.tar.gz
rust-7e187e8e4b0a12b9adc0d24dc30dffde6ceaba4a.zip
remove references to `PathBuf::as_mut_vec` in `PathBuf::_set_extension`
Diffstat (limited to 'library/std/src')
-rw-r--r--library/std/src/path.rs11
1 files changed, 5 insertions, 6 deletions
diff --git a/library/std/src/path.rs b/library/std/src/path.rs
index fb7476a3b26..fb488ae94a1 100644
--- a/library/std/src/path.rs
+++ b/library/std/src/path.rs
@@ -1511,15 +1511,14 @@ impl PathBuf {
         // truncate until right after the file stem
         let end_file_stem = file_stem[file_stem.len()..].as_ptr().addr();
         let start = self.inner.as_encoded_bytes().as_ptr().addr();
-        let v = self.as_mut_vec();
-        v.truncate(end_file_stem.wrapping_sub(start));
+        self.inner.truncate(end_file_stem.wrapping_sub(start));
 
         // add the new extension, if any
-        let new = extension.as_encoded_bytes();
+        let new = extension;
         if !new.is_empty() {
-            v.reserve_exact(new.len() + 1);
-            v.push(b'.');
-            v.extend_from_slice(new);
+            self.inner.reserve_exact(new.len() + 1);
+            self.inner.push(OsStr::new("."));
+            self.inner.push(new);
         }
 
         true