Guarantee try_reserve
preserves the contents on error
Update doc comments to make the guarantee explicit. However, some implementations does not have the statement though. * `HashMap`, `HashSet`: require guarantees on hashbrown side. * `PathBuf`: simply redirecting to `OsString`. Fixes #99606.
This commit is contained in:
parent
cc4dd6fc9f
commit
2bb7e1e6ed
@ -1010,7 +1010,8 @@ pub fn try_reserve_exact(&mut self, additional: usize) -> Result<(), TryReserveE
|
||||
/// current length. The allocator may reserve more space to speculatively
|
||||
/// avoid frequent allocations. After calling `try_reserve`, capacity will be
|
||||
/// greater than or equal to `self.len() + additional` if it returns
|
||||
/// `Ok(())`. Does nothing if capacity is already sufficient.
|
||||
/// `Ok(())`. Does nothing if capacity is already sufficient. This method
|
||||
/// preserves the contents even if an error occurs.
|
||||
///
|
||||
/// # Errors
|
||||
///
|
||||
|
@ -794,7 +794,8 @@ pub fn try_reserve_exact(&mut self, additional: usize) -> Result<(), TryReserveE
|
||||
/// in the given deque. The collection may reserve more space to speculatively avoid
|
||||
/// frequent reallocations. After calling `try_reserve`, capacity will be
|
||||
/// greater than or equal to `self.len() + additional` if it returns
|
||||
/// `Ok(())`. Does nothing if capacity is already sufficient.
|
||||
/// `Ok(())`. Does nothing if capacity is already sufficient. This method
|
||||
/// preserves the contents even if an error occurs.
|
||||
///
|
||||
/// # Errors
|
||||
///
|
||||
|
@ -1080,7 +1080,8 @@ pub fn reserve_exact(&mut self, additional: usize) {
|
||||
/// current length. The allocator may reserve more space to speculatively
|
||||
/// avoid frequent allocations. After calling `try_reserve`, capacity will be
|
||||
/// greater than or equal to `self.len() + additional` if it returns
|
||||
/// `Ok(())`. Does nothing if capacity is already sufficient.
|
||||
/// `Ok(())`. Does nothing if capacity is already sufficient. This method
|
||||
/// preserves the contents even if an error occurs.
|
||||
///
|
||||
/// # Errors
|
||||
///
|
||||
|
@ -875,7 +875,8 @@ pub fn reserve_exact(&mut self, additional: usize) {
|
||||
/// in the given `Vec<T>`. The collection may reserve more space to speculatively avoid
|
||||
/// frequent reallocations. After calling `try_reserve`, capacity will be
|
||||
/// greater than or equal to `self.len() + additional` if it returns
|
||||
/// `Ok(())`. Does nothing if capacity is already sufficient.
|
||||
/// `Ok(())`. Does nothing if capacity is already sufficient. This method
|
||||
/// preserves the contents even if an error occurs.
|
||||
///
|
||||
/// # Errors
|
||||
///
|
||||
|
@ -290,7 +290,8 @@ pub fn reserve(&mut self, additional: usize) {
|
||||
/// in the given `OsString`. The string may reserve more space to speculatively avoid
|
||||
/// frequent reallocations. After calling `try_reserve`, capacity will be
|
||||
/// greater than or equal to `self.len() + additional` if it returns `Ok(())`.
|
||||
/// Does nothing if capacity is already sufficient.
|
||||
/// Does nothing if capacity is already sufficient. This method preserves
|
||||
/// the contents even if an error occurs.
|
||||
///
|
||||
/// See the main `OsString` documentation information about encoding and capacity units.
|
||||
///
|
||||
|
@ -236,7 +236,8 @@ pub fn reserve(&mut self, additional: usize) {
|
||||
/// 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.
|
||||
/// capacity is already sufficient. This method preserves the contents even
|
||||
/// if an error occurs.
|
||||
///
|
||||
/// # Errors
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user