about summary refs log tree commit diff
diff options
context:
space:
mode:
authorCorey Farwell <coreyf@rwell.org>2017-03-12 16:21:58 -0400
committerCorey Farwell <coreyf@rwell.org>2017-03-14 09:29:38 -0400
commit5537955b1747f8f8c873cf7681ec8a497404e730 (patch)
treed58a1797b68fd54e486cbd75fe11429fffd81511
parent4d57d92f071d24a4c189cc8aef897be25bcd9d55 (diff)
downloadrust-5537955b1747f8f8c873cf7681ec8a497404e730.tar.gz
rust-5537955b1747f8f8c873cf7681ec8a497404e730.zip
Add doc example for `OsString::reserve_exact`.
-rw-r--r--src/libstd/ffi/os_str.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/libstd/ffi/os_str.rs b/src/libstd/ffi/os_str.rs
index bdd8ce5e6d8..d960d76146f 100644
--- a/src/libstd/ffi/os_str.rs
+++ b/src/libstd/ffi/os_str.rs
@@ -210,6 +210,16 @@ impl OsString {
     /// Note that the allocator may give the collection more space than it
     /// requests. Therefore capacity can not be relied upon to be precisely
     /// minimal. Prefer reserve if future insertions are expected.
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// use std::ffi::OsString;
+    ///
+    /// let mut s = OsString::new();
+    /// s.reserve_exact(10);
+    /// assert!(s.capacity() >= 10);
+    /// ```
     #[stable(feature = "osstring_simple_functions", since = "1.9.0")]
     pub fn reserve_exact(&mut self, additional: usize) {
         self.inner.reserve_exact(additional)