We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 469a219 + 7e79f91 commit 7b3e593Copy full SHA for 7b3e593
library/std/src/ffi/os_str.rs
@@ -550,11 +550,15 @@ impl OsString {
550
OsStr::from_inner_mut(self.inner.leak())
551
}
552
553
- /// Provides plumbing to core `Vec::truncate`.
554
- /// More well behaving alternative to allowing outer types
555
- /// full mutable access to the core `Vec`.
+ /// Truncate the the `OsString` to the specified length.
+ ///
+ /// # Panics
556
+ /// Panics if `len` does not lie on a valid `OsStr` boundary
557
+ /// (as described in [`OsStr::slice_encoded_bytes`]).
558
#[inline]
- 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);
562
self.inner.truncate(len);
563
564
0 commit comments