Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 0db5415

Browse files
committedJun 24, 2024
windows platforms accounted for, should close #126333
1 parent c477e57 commit 0db5415

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed
 

‎library/std/src/sys/os_str/wtf8.rs

+13-3
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,20 @@ impl Buf {
165165
self.as_slice().into_rc()
166166
}
167167

168-
/// Part of a hack to make PathBuf::push/pop more efficient.
168+
/// More well behaving alternative to allowing outer types
169+
/// full mutable access to the core `Vec`.
170+
/// Provides plumbing to core `Vec::truncate`.
169171
#[inline]
170-
pub(crate) fn as_mut_vec_for_path_buf(&mut self) -> &mut Vec<u8> {
171-
self.inner.as_mut_vec_for_path_buf()
172+
pub(crate) fn truncate(&mut self, len: usize) {
173+
self.inner.truncate(len);
174+
}
175+
176+
/// More well behaving alternative to allowing outer types
177+
/// full mutable access to the core `Vec`.
178+
/// Provides plumbing to core `Vec::extend_from_slice`.
179+
#[inline]
180+
pub(crate) fn extend_from_slice(&mut self, other: &[u8]) {
181+
self.inner.extend_from_slice(other);
172182
}
173183
}
174184

‎library/std/src/sys_common/wtf8.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -474,13 +474,12 @@ impl Wtf8Buf {
474474
Wtf8Buf { bytes: bytes.into_vec(), is_known_utf8: false }
475475
}
476476

477-
/// Part of a hack to make PathBuf::push/pop more efficient.
477+
/// More well behaving alternative to allowing outer types
478+
/// full mutable access to the core `Vec`.
479+
/// Provides plumbing to core `Vec::extend_from_slice`.
478480
#[inline]
479-
pub(crate) fn as_mut_vec_for_path_buf(&mut self) -> &mut Vec<u8> {
480-
// FIXME: this function should not even exist, as it implies violating Wtf8Buf invariants
481-
// For now, simply assume that is about to happen.
482-
self.is_known_utf8 = false;
483-
&mut self.bytes
481+
pub(crate) fn extend_from_slice(&mut self, other: &[u8]) {
482+
self.bytes.extend_from_slice(other);
484483
}
485484
}
486485

0 commit comments

Comments
 (0)
Failed to load comments.