]> git.lizzy.rs Git - rust.git/commitdiff
Add doc example for `OsString::reserve_exact`.
authorCorey Farwell <coreyf@rwell.org>
Sun, 12 Mar 2017 20:21:58 +0000 (16:21 -0400)
committerCorey Farwell <coreyf@rwell.org>
Tue, 14 Mar 2017 13:29:38 +0000 (09:29 -0400)
src/libstd/ffi/os_str.rs

index bdd8ce5e6d8543ead8bb6e4ba98dc6096dfaf91f..d960d76146fe967e3f3b1bc5b62ef396adac005c 100644 (file)
@@ -210,6 +210,16 @@ pub fn reserve(&mut self, additional: usize) {
     /// 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)