talira

arrayvec

Rust vector and string types with fixed capacity, stored inline

open sourceApache-2.0 OR MITfree

arrayvec is a Rust crate with ArrayVec and ArrayString, array-backed vector and string types with a fixed capacity that store their contents inline, so they can live on the stack without heap allocation. It works in no_std builds when its default std feature is turned off, and optional features add serde serialization and Zeroize support. Install it from crates.io as arrayvec.

Problems it solves

  • keep a small list on the stack in Rust without heap allocation
  • use a vector-like type in a no_std Rust embedded project
  • store a short string inline in a Rust struct

Features

  • ArrayVec: a fixed-capacity vector backed by an array
  • ArrayString: a fixed-capacity string stored inline
  • no_std support
  • optional serde and Zeroize support

Alternatives

The same job

These do what arrayvec does.

  1. SmallVec A Rust vector that keeps a few items on the stack before it allocates

Compare arrayvec with the top 3