Address comments

Signed-off-by: Xuanwo <github@xuanwo.io>
This commit is contained in:
Xuanwo 2021-12-29 14:02:20 +08:00
parent 9166428be1
commit b07ae1c4d5
No known key found for this signature in database
GPG key ID: C423B4FA6B48E945
2 changed files with 10 additions and 10 deletions

View file

@ -266,7 +266,7 @@ pub fn reserve(&mut self, additional: usize) {
self.inner.reserve(additional)
}
/// Tries to reserve capacity for at least `additional` more elements to be inserted
/// Tries to reserve capacity for at least `additional` more length units
/// in the given `OsString`. The string may reserve more space to avoid
/// frequent reallocations. After calling `try_reserve`, capacity will be
/// greater than or equal to `self.len() + additional`. Does nothing if
@ -288,7 +288,7 @@ pub fn reserve(&mut self, additional: usize) {
/// let mut s = OsString::new();
///
/// // Pre-reserve the memory, exiting if we can't
/// s.try_reserve(data.len())?;
/// s.try_reserve(OsString::from(data).len())?;
///
/// // Now we know this can't OOM in the middle of our complex work
/// s.push(data);
@ -329,12 +329,12 @@ pub fn reserve_exact(&mut self, additional: usize) {
}
/// Tries to reserve the minimum capacity for exactly `additional`
/// elements to be inserted in the given `OsString`. After calling
/// more length units in the given `OsString`. After calling
/// `try_reserve_exact`, capacity will be greater than or equal to
/// `self.len() + additional` if it returns `Ok(())`.
/// Does nothing if the capacity is already sufficient.
///
/// Note that the allocator may give the collection more space than it
/// Note that the allocator may give the `OsString` more space than it
/// requests. Therefore, capacity can not be relied upon to be precisely
/// minimal. Prefer [`try_reserve`] if future insertions are expected.
///
@ -353,10 +353,10 @@ pub fn reserve_exact(&mut self, additional: usize) {
/// use std::collections::TryReserveError;
///
/// fn find_max_slow(data: &str) -> Result<OsString, TryReserveError> {
/// let mut s = OsString::from(data);
/// let mut s = OsString::new();
///
/// // Pre-reserve the memory, exiting if we can't
/// s.try_reserve_exact(data.len())?;
/// s.try_reserve_exact(OsString::from(data).len())?;
///
/// // Now we know this can't OOM in the middle of our complex work
/// s.push(data);

View file

@ -232,8 +232,8 @@ pub fn reserve(&mut self, additional: usize) {
self.bytes.reserve(additional)
}
/// Tries to reserve capacity for at least `additional` more elements to be inserted
/// in the given `Wtf8Buf`. The collection may reserve more space to avoid
/// Tries to reserve capacity for at least `additional` more length units
/// in the given `Wtf8Buf`. The `Wtf8Buf` may reserve more space to avoid
/// frequent reallocations. After calling `try_reserve`, capacity will be
/// greater than or equal to `self.len() + additional`. Does nothing if
/// capacity is already sufficient.
@ -253,12 +253,12 @@ pub fn reserve_exact(&mut self, additional: usize) {
}
/// Tries to reserve the minimum capacity for exactly `additional`
/// elements to be inserted in the given `Wtf8Buf`. After calling
/// length units in the given `Wtf8Buf`. After calling
/// `try_reserve_exact`, capacity will be greater than or equal to
/// `self.len() + additional` if it returns `Ok(())`.
/// Does nothing if the capacity is already sufficient.
///
/// Note that the allocator may give the collection more space than it
/// Note that the allocator may give the `Wtf8Buf` more space than it
/// requests. Therefore, capacity can not be relied upon to be precisely
/// minimal. Prefer [`try_reserve`] if future insertions are expected.
///