Skip to content

Feature: Support a fixed-dynamic-capacity Vec #353

@kupiakos

Description

@kupiakos

So, a dynamically sized Vec, but still with a max capacity. This would remain heapless, as you can construct the slice on the stack or static and pass it in. There are some particular advantages to this approach in an embedded environment, the biggest of which being the lack of monomorphization required to support multiple capacities. A SliceVec<'a, T> with dynamic length N can be produced via a method on &'a mut Vec<T, N>. It can also be safely produced from a &'a mut [MaybeUninit<T>] and &'a mut [T], since we never write new uninit data.

A SliceVec can also be used on external buffers, such as keeping track of how many bytes of an uninit buffer have been written to and provide a safe method to retrieve the initialized bytes. This is particularly useful for zero-copy deserialization.

If I were send a PR to add this, would it be accepted? This is a blocker for my team switching to heapless off of FixedVec, which has less support and fewer types to work with.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions