Skip to content

Rust collections should support inline capacity specified as a compile-time integer #15748

Closed
@zwarich

Description

@zwarich

Many C++ projects (including all web browser engines that I am aware of, LLVM, etc.) use their own C++ collections where collections have an inline capacity specified at compile time, e.g. Vec<T, 4>. This means that the collection reserves space for a fixed number of elements, and it until its capacity goes above the inline capacity it can avoid a heap allocation.

Obviously, this feature requires support for type-level integers in the first place. It also increases the pressure to deal with existing ergonomic issues regarding type constructor parameters, since e.g. HashMap would have key, value, hasher, inline capacity, and allocator parameters.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-enhancementCategory: An issue proposing an enhancement or a PR with one.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions