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 7b3e593

Browse files
authoredNov 23, 2024
Rollup merge of #133264 - lolbinarycat:os-string-truncate, r=joboet
implement OsString::truncate part of #133262
2 parents 469a219 + 7e79f91 commit 7b3e593

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed
 

‎library/std/src/ffi/os_str.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -550,11 +550,15 @@ impl OsString {
550550
OsStr::from_inner_mut(self.inner.leak())
551551
}
552552

553-
/// Provides plumbing to core `Vec::truncate`.
554-
/// More well behaving alternative to allowing outer types
555-
/// full mutable access to the core `Vec`.
553+
/// Truncate the the `OsString` to the specified length.
554+
///
555+
/// # Panics
556+
/// Panics if `len` does not lie on a valid `OsStr` boundary
557+
/// (as described in [`OsStr::slice_encoded_bytes`]).
556558
#[inline]
557-
pub(crate) fn truncate(&mut self, len: usize) {
559+
#[unstable(feature = "os_string_truncate", issue = "133262")]
560+
pub fn truncate(&mut self, len: usize) {
561+
self.as_os_str().inner.check_public_boundary(len);
558562
self.inner.truncate(len);
559563
}
560564

0 commit comments

Comments
 (0)
Failed to load comments.