about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorCorey Farwell <coreyf@rwell.org>2017-03-12 16:22:12 -0400
committerCorey Farwell <coreyf@rwell.org>2017-03-14 09:30:00 -0400
commitbda57dbc059a15222173b40a5e4d7e5579adcfec (patch)
tree76788db4683ec5e57d174daea61ded63ed2e0aa9 /src/libstd
parent5537955b1747f8f8c873cf7681ec8a497404e730 (diff)
downloadrust-bda57dbc059a15222173b40a5e4d7e5579adcfec.tar.gz
rust-bda57dbc059a15222173b40a5e4d7e5579adcfec.zip
Add doc example for `OsString::shrink_to_fit`.
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/ffi/os_str.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/libstd/ffi/os_str.rs b/src/libstd/ffi/os_str.rs
index d960d76146f..9da6eca3408 100644
--- a/src/libstd/ffi/os_str.rs
+++ b/src/libstd/ffi/os_str.rs
@@ -226,6 +226,22 @@ impl OsString {
     }
 
     /// 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()