1
Fork 0

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:
YOSHIOKA Takuma 2022-08-10 01:51:38 +09:00
parent cc4dd6fc9f
commit 2bb7e1e6ed
No known key found for this signature in database
GPG key ID: EF2059A2B64518D7
6 changed files with 12 additions and 6 deletions

View file

@ -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
/// 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
///