Rollup merge of #133264 - lolbinarycat:os-string-truncate, r=joboet
implement OsString::truncate part of #133262
This commit is contained in:
commit
7b3e593fb1
1 changed files with 8 additions and 4 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue