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
6 changed files with 12 additions and 6 deletions
|
@ -1010,7 +1010,8 @@ impl<T> BinaryHeap<T> {
|
||||||
/// current length. The allocator may reserve more space to speculatively
|
/// current length. The allocator may reserve more space to speculatively
|
||||||
/// avoid frequent allocations. After calling `try_reserve`, capacity will be
|
/// avoid frequent allocations. After calling `try_reserve`, capacity will be
|
||||||
/// greater than or equal to `self.len() + additional` if it returns
|
/// 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
|
/// # Errors
|
||||||
///
|
///
|
||||||
|
|
|
@ -794,7 +794,8 @@ impl<T, A: Allocator> VecDeque<T, A> {
|
||||||
/// in the given deque. The collection may reserve more space to speculatively avoid
|
/// in the given deque. The collection may reserve more space to speculatively avoid
|
||||||
/// frequent reallocations. After calling `try_reserve`, capacity will be
|
/// frequent reallocations. After calling `try_reserve`, capacity will be
|
||||||
/// greater than or equal to `self.len() + additional` if it returns
|
/// 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
|
/// # Errors
|
||||||
///
|
///
|
||||||
|
|
|
@ -1080,7 +1080,8 @@ impl String {
|
||||||
/// current length. The allocator may reserve more space to speculatively
|
/// current length. The allocator may reserve more space to speculatively
|
||||||
/// avoid frequent allocations. After calling `try_reserve`, capacity will be
|
/// avoid frequent allocations. After calling `try_reserve`, capacity will be
|
||||||
/// greater than or equal to `self.len() + additional` if it returns
|
/// 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
|
/// # Errors
|
||||||
///
|
///
|
||||||
|
|
|
@ -875,7 +875,8 @@ impl<T, A: Allocator> Vec<T, A> {
|
||||||
/// in the given `Vec<T>`. The collection may reserve more space to speculatively avoid
|
/// in the given `Vec<T>`. The collection may reserve more space to speculatively avoid
|
||||||
/// frequent reallocations. After calling `try_reserve`, capacity will be
|
/// frequent reallocations. After calling `try_reserve`, capacity will be
|
||||||
/// greater than or equal to `self.len() + additional` if it returns
|
/// 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
|
/// # Errors
|
||||||
///
|
///
|
||||||
|
|
|
@ -290,7 +290,8 @@ impl OsString {
|
||||||
/// in the given `OsString`. The string may reserve more space to speculatively avoid
|
/// in the given `OsString`. The string may reserve more space to speculatively avoid
|
||||||
/// frequent reallocations. After calling `try_reserve`, capacity will be
|
/// frequent reallocations. After calling `try_reserve`, capacity will be
|
||||||
/// greater than or equal to `self.len() + additional` if it returns `Ok(())`.
|
/// 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.
|
/// See the main `OsString` documentation information about encoding and capacity units.
|
||||||
///
|
///
|
||||||
|
|
|
@ -236,7 +236,8 @@ impl Wtf8Buf {
|
||||||
/// in the given `Wtf8Buf`. The `Wtf8Buf` may reserve more space to avoid
|
/// in the given `Wtf8Buf`. The `Wtf8Buf` may reserve more space to avoid
|
||||||
/// frequent reallocations. After calling `try_reserve`, capacity will be
|
/// frequent reallocations. After calling `try_reserve`, capacity will be
|
||||||
/// greater than or equal to `self.len() + additional`. Does nothing if
|
/// 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
|
/// # Errors
|
||||||
///
|
///
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue