@@ -266,7 +266,7 @@ impl OsString {
266
266
self . inner . reserve ( additional)
267
267
}
268
268
269
- /// Tries to reserve capacity for at least `additional` more elements to be inserted
269
+ /// Tries to reserve capacity for at least `additional` more length units
270
270
/// in the given `OsString`. The string may reserve more space to avoid
271
271
/// frequent reallocations. After calling `try_reserve`, capacity will be
272
272
/// greater than or equal to `self.len() + additional`. Does nothing if
@@ -288,7 +288,7 @@ impl OsString {
288
288
/// let mut s = OsString::new();
289
289
///
290
290
/// // Pre-reserve the memory, exiting if we can't
291
- /// s.try_reserve(data.len())?;
291
+ /// s.try_reserve(OsString::from( data) .len())?;
292
292
///
293
293
/// // Now we know this can't OOM in the middle of our complex work
294
294
/// s.push(data);
@@ -329,12 +329,12 @@ impl OsString {
329
329
}
330
330
331
331
/// Tries to reserve the minimum capacity for exactly `additional`
332
- /// elements to be inserted in the given `OsString`. After calling
332
+ /// more length units in the given `OsString`. After calling
333
333
/// `try_reserve_exact`, capacity will be greater than or equal to
334
334
/// `self.len() + additional` if it returns `Ok(())`.
335
335
/// Does nothing if the capacity is already sufficient.
336
336
///
337
- /// Note that the allocator may give the collection more space than it
337
+ /// Note that the allocator may give the `OsString` more space than it
338
338
/// requests. Therefore, capacity can not be relied upon to be precisely
339
339
/// minimal. Prefer [`try_reserve`] if future insertions are expected.
340
340
///
@@ -353,10 +353,10 @@ impl OsString {
353
353
/// use std::collections::TryReserveError;
354
354
///
355
355
/// fn find_max_slow(data: &str) -> Result<OsString, TryReserveError> {
356
- /// let mut s = OsString::from(data );
356
+ /// let mut s = OsString::new( );
357
357
///
358
358
/// // Pre-reserve the memory, exiting if we can't
359
- /// s.try_reserve_exact(data.len())?;
359
+ /// s.try_reserve_exact(OsString::from( data) .len())?;
360
360
///
361
361
/// // Now we know this can't OOM in the middle of our complex work
362
362
/// s.push(data);
0 commit comments