diff options
| author | Michael Goulet <michael@errs.io> | 2024-11-22 21:07:41 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-11-22 21:07:41 -0500 |
| commit | 7b3e593fb12f1ae1212ea42c054695f7b1c17a63 (patch) | |
| tree | b7abf307d500ab81a3f678bad87eb57b5e769334 | |
| parent | 469a219c8fbe4977aa27b454dc8cf1208751d828 (diff) | |
| parent | 7e79f913903a5c9f82e3f2e8afffa535159fcf54 (diff) | |
| download | rust-7b3e593fb12f1ae1212ea42c054695f7b1c17a63.tar.gz rust-7b3e593fb12f1ae1212ea42c054695f7b1c17a63.zip | |
Rollup merge of #133264 - lolbinarycat:os-string-truncate, r=joboet
implement OsString::truncate part of #133262
| -rw-r--r-- | library/std/src/ffi/os_str.rs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/library/std/src/ffi/os_str.rs b/library/std/src/ffi/os_str.rs index 79dfb47d0c4..328185d1f2b 100644 --- a/library/std/src/ffi/os_str.rs +++ b/library/std/src/ffi/os_str.rs @@ -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); } |
