@@ -266,7 +266,7 @@ impl OsString {
266266 self . inner . reserve ( additional)
267267 }
268268
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
270270 /// in the given `OsString`. The string may reserve more space to avoid
271271 /// frequent reallocations. After calling `try_reserve`, capacity will be
272272 /// greater than or equal to `self.len() + additional`. Does nothing if
@@ -288,7 +288,7 @@ impl OsString {
288288 /// let mut s = OsString::new();
289289 ///
290290 /// // Pre-reserve the memory, exiting if we can't
291- /// s.try_reserve(data.len())?;
291+ /// s.try_reserve(OsString::from( data) .len())?;
292292 ///
293293 /// // Now we know this can't OOM in the middle of our complex work
294294 /// s.push(data);
@@ -329,12 +329,12 @@ impl OsString {
329329 }
330330
331331 /// 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
333333 /// `try_reserve_exact`, capacity will be greater than or equal to
334334 /// `self.len() + additional` if it returns `Ok(())`.
335335 /// Does nothing if the capacity is already sufficient.
336336 ///
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
338338 /// requests. Therefore, capacity can not be relied upon to be precisely
339339 /// minimal. Prefer [`try_reserve`] if future insertions are expected.
340340 ///
@@ -353,10 +353,10 @@ impl OsString {
353353 /// use std::collections::TryReserveError;
354354 ///
355355 /// fn find_max_slow(data: &str) -> Result<OsString, TryReserveError> {
356- /// let mut s = OsString::from(data );
356+ /// let mut s = OsString::new( );
357357 ///
358358 /// // 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())?;
360360 ///
361361 /// // Now we know this can't OOM in the middle of our complex work
362362 /// s.push(data);
0 commit comments