We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
OsString::shrink_to_fit
1 parent 5537955 commit bda57dbCopy full SHA for bda57db
src/libstd/ffi/os_str.rs
@@ -226,6 +226,22 @@ impl OsString {
226
}
227
228
/// Shrinks the capacity of the `OsString` to match its length.
229
+ ///
230
+ /// # Examples
231
232
+ /// ```
233
+ /// #![feature(osstring_shrink_to_fit)]
234
235
+ /// use std::ffi::OsString;
236
237
+ /// let mut s = OsString::from("foo");
238
239
+ /// s.reserve(100);
240
+ /// assert!(s.capacity() >= 100);
241
242
+ /// s.shrink_to_fit();
243
+ /// assert_eq!(3, s.capacity());
244
245
#[unstable(feature = "osstring_shrink_to_fit", issue = "40421")]
246
pub fn shrink_to_fit(&mut self) {
247
self.inner.shrink_to_fit()
0 commit comments