diff options
| author | ash <97464181+Borgerr@users.noreply.github.com> | 2024-06-23 08:36:23 -0600 |
|---|---|---|
| committer | ash <97464181+Borgerr@users.noreply.github.com> | 2024-06-25 07:36:34 -0600 |
| commit | b08cd69684e4b121399b3ea0f9ee6cc4a51cad07 (patch) | |
| tree | 1f6ec4f4305608db64830fb26f642bcfc6258f20 | |
| parent | 2155c6c47761391673a2794430dc78436c25bbf8 (diff) | |
| download | rust-b08cd69684e4b121399b3ea0f9ee6cc4a51cad07.tar.gz rust-b08cd69684e4b121399b3ea0f9ee6cc4a51cad07.zip | |
inner truncate methods for UEFI platforms
| -rw-r--r-- | library/std/src/ffi/os_str.rs | 5 | ||||
| -rw-r--r-- | library/std/src/path.rs | 6 | ||||
| -rw-r--r-- | library/std/src/sys/os_str/bytes.rs | 5 |
3 files changed, 13 insertions, 3 deletions
diff --git a/library/std/src/ffi/os_str.rs b/library/std/src/ffi/os_str.rs index f6b9de26c1c..318fe205e0f 100644 --- a/library/std/src/ffi/os_str.rs +++ b/library/std/src/ffi/os_str.rs @@ -557,6 +557,11 @@ impl OsString { pub(crate) fn as_mut_vec_for_path_buf(&mut self) -> &mut Vec<u8> { self.inner.as_mut_vec_for_path_buf() } + + #[inline] + pub(crate) fn truncate(&mut self, len: usize) { + self.inner.truncate(len); + } } #[stable(feature = "rust1", since = "1.0.0")] diff --git a/library/std/src/path.rs b/library/std/src/path.rs index 13947122dca..fb7476a3b26 100644 --- a/library/std/src/path.rs +++ b/library/std/src/path.rs @@ -1305,7 +1305,7 @@ impl PathBuf { // absolute `path` replaces `self` if path.is_absolute() || path.prefix().is_some() { - self.as_mut_vec().truncate(0); + self.inner.truncate(0); // verbatim paths need . and .. removed } else if comps.prefix_verbatim() && !path.inner.is_empty() { @@ -1350,7 +1350,7 @@ impl PathBuf { // `path` has a root but no prefix, e.g., `\windows` (Windows only) } else if path.has_root() { let prefix_len = self.components().prefix_remaining(); - self.as_mut_vec().truncate(prefix_len); + self.inner.truncate(prefix_len); // `path` is a pure relative path } else if need_sep { @@ -1383,7 +1383,7 @@ impl PathBuf { pub fn pop(&mut self) -> bool { match self.parent().map(|p| p.as_u8_slice().len()) { Some(len) => { - self.as_mut_vec().truncate(len); + self.inner.truncate(len); true } None => false, diff --git a/library/std/src/sys/os_str/bytes.rs b/library/std/src/sys/os_str/bytes.rs index f7c6b0877aa..e494f7d1dea 100644 --- a/library/std/src/sys/os_str/bytes.rs +++ b/library/std/src/sys/os_str/bytes.rs @@ -207,6 +207,11 @@ impl Buf { pub(crate) fn as_mut_vec_for_path_buf(&mut self) -> &mut Vec<u8> { &mut self.inner } + + #[inline] + pub(crate) fn truncate(&mut self, len: usize) { + self.inner.truncate(len); + } } impl Slice { |
