rust-embedded / rust-embedded/heapless

Feature: Support a fixed-dynamic-capacity Vec

Open
#353 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Rust
Stars
2k
Forks
253
Avg merge
1d 2h
Merged PRs (30d)
1

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no repository files or tests; begin by reviewing the existing Vec API and the linked FixedVec reference. Clarify and agree on the SliceVec API, supported buffer forms, safety guarantees, and tests before implementation.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
embedded-iot
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.