Add doc example for `OsString::reserve_exact`.

This commit is contained in:
Corey Farwell 2017-03-12 16:21:58 -04:00
parent 4d57d92f07
commit 5537955b17
1 changed files with 10 additions and 0 deletions

View File

@ -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)