Skip to content

Commit 5537955

Browse files
committed
Add doc example for OsString::reserve_exact.
1 parent 4d57d92 commit 5537955

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/libstd/ffi/os_str.rs

+10
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,16 @@ impl OsString {
210210
/// Note that the allocator may give the collection more space than it
211211
/// requests. Therefore capacity can not be relied upon to be precisely
212212
/// minimal. Prefer reserve if future insertions are expected.
213+
///
214+
/// # Examples
215+
///
216+
/// ```
217+
/// use std::ffi::OsString;
218+
///
219+
/// let mut s = OsString::new();
220+
/// s.reserve_exact(10);
221+
/// assert!(s.capacity() >= 10);
222+
/// ```
213223
#[stable(feature = "osstring_simple_functions", since = "1.9.0")]
214224
pub fn reserve_exact(&mut self, additional: usize) {
215225
self.inner.reserve_exact(additional)

0 commit comments

Comments
 (0)