Skip to content

Commit

Permalink
Rollup merge of rust-lang#133264 - lolbinarycat:os-string-truncate, r…
Browse files Browse the repository at this point in the history
…=joboet

implement OsString::truncate

part of rust-lang#133262
  • Loading branch information
compiler-errors authored Nov 23, 2024
2 parents fb6f0c2 + 38d4c11 commit a4f797e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions std/src/ffi/os_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -550,11 +550,15 @@ impl OsString {
OsStr::from_inner_mut(self.inner.leak())
}

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

Expand Down

0 comments on commit a4f797e

Please sign in to comment.