Skip to content

Commit 4d57d92

Browse files
committed
Add doc example for OsString::reserve.
1 parent 9a7b789 commit 4d57d92

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
@@ -188,6 +188,16 @@ impl OsString {
188188
/// in the given `OsString`.
189189
///
190190
/// The collection may reserve more space to avoid frequent reallocations.
191+
///
192+
/// # Examples
193+
///
194+
/// ```
195+
/// use std::ffi::OsString;
196+
///
197+
/// let mut s = OsString::new();
198+
/// s.reserve(10);
199+
/// assert!(s.capacity() >= 10);
200+
/// ```
191201
#[stable(feature = "osstring_simple_functions", since = "1.9.0")]
192202
pub fn reserve(&mut self, additional: usize) {
193203
self.inner.reserve(additional)

0 commit comments

Comments
 (0)