Skip to content

Guarantees of content preservation on try_reserve failure? #99606

Closed
@lo48576

Description

@lo48576

Location

Any try_reserve methods of container types (12 in Rust 1,62.1, including duplicated ones in alloc), and maybe corresponding try_reserve_exact methods.

  • std::collections::BinaryHeap::try_reserve[_exact]
  • std::collections::VecDeque::try_reserve[_exact]
  • std::collections::HashMap::try_reserve
  • std::collections::HashSet::try_reserve
  • std::ffi::OsString::try_reserve[_exact]
  • std::path::PathBuf::try_reserve[_exact]
  • std::string::String::try_reserve[_exact]
  • std::vec::Vec::try_reserve[_exact]
  • ... and corresponding methods in alloc.

Summary

Documentations for try_reserve describes "If the capacity overflows, or the allocator reports a failure, then an error is returned.".
However, it does not give any guarantees about whether the content is preserved or not on that error.
This guarantee (or absence of the guarantee) should be explicitly described.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.disposition-mergeThis issue / PR is in PFCP or FCP with a disposition to merge it.finished-final-comment-periodThe final comment period is finished for this PR / Issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions