mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-29 12:36:35 +03:00
Add doc example for OsString::shrink_to_fit.
This commit is contained in:
@@ -226,6 +226,22 @@ pub fn reserve_exact(&mut self, additional: usize) {
|
||||
}
|
||||
|
||||
/// Shrinks the capacity of the `OsString` to match its length.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(osstring_shrink_to_fit)]
|
||||
///
|
||||
/// use std::ffi::OsString;
|
||||
///
|
||||
/// let mut s = OsString::from("foo");
|
||||
///
|
||||
/// s.reserve(100);
|
||||
/// assert!(s.capacity() >= 100);
|
||||
///
|
||||
/// s.shrink_to_fit();
|
||||
/// assert_eq!(3, s.capacity());
|
||||
/// ```
|
||||
#[unstable(feature = "osstring_shrink_to_fit", issue = "40421")]
|
||||
pub fn shrink_to_fit(&mut self) {
|
||||
self.inner.shrink_to_fit()
|
||||
|
||||
Reference in New Issue
Block a user