Skip to content

Commit b07ae1c

Browse files
committed
Address comments
Signed-off-by: Xuanwo <[email protected]>
1 parent 9166428 commit b07ae1c

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

library/std/src/ffi/os_str.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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);

library/std/src/sys_common/wtf8.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,8 @@ impl Wtf8Buf {
232232
self.bytes.reserve(additional)
233233
}
234234

235-
/// Tries to reserve capacity for at least `additional` more elements to be inserted
236-
/// in the given `Wtf8Buf`. The collection may reserve more space to avoid
235+
/// Tries to reserve capacity for at least `additional` more length units
236+
/// in the given `Wtf8Buf`. The `Wtf8Buf` may reserve more space to avoid
237237
/// frequent reallocations. After calling `try_reserve`, capacity will be
238238
/// greater than or equal to `self.len() + additional`. Does nothing if
239239
/// capacity is already sufficient.
@@ -253,12 +253,12 @@ impl Wtf8Buf {
253253
}
254254

255255
/// Tries to reserve the minimum capacity for exactly `additional`
256-
/// elements to be inserted in the given `Wtf8Buf`. After calling
256+
/// length units in the given `Wtf8Buf`. After calling
257257
/// `try_reserve_exact`, capacity will be greater than or equal to
258258
/// `self.len() + additional` if it returns `Ok(())`.
259259
/// Does nothing if the capacity is already sufficient.
260260
///
261-
/// Note that the allocator may give the collection more space than it
261+
/// Note that the allocator may give the `Wtf8Buf` more space than it
262262
/// requests. Therefore, capacity can not be relied upon to be precisely
263263
/// minimal. Prefer [`try_reserve`] if future insertions are expected.
264264
///

0 commit comments

Comments
 (0)