Skip to content

Commit a4f797e

Browse files
Rollup merge of rust-lang#133264 - lolbinarycat:os-string-truncate, r=joboet
implement OsString::truncate part of rust-lang#133262
2 parents fb6f0c2 + 38d4c11 commit a4f797e

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

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)