Thanks to visit codestin.com
Credit goes to lib.rs

19 releases (9 breaking)

Uses new Rust 2024

0.10.0 Jun 25, 2025
0.9.0 May 28, 2025

#1633 in Algorithms

Codestin Search App Codestin Search App Codestin Search App

1,331 downloads per month
Used in 2 crates

GPL-3.0-only

110KB
2K SLoC

Tiny-Vec

A dynamic array with an initial stack-based buffer, for small collections.

It aims to have a similar API to std::vec::Vec, but allowing to optimize small lists. It starts as a stack-based buffer, and automatically switches to the heap when the capacity grows over a certain number of elements.

The tiny-str crate provides TinyString, which is a String backed by a TinyVec, just like std::string::String is built on top of std::vec::Vec.

== Documentation == To build the documentation, run cargo doc Or browse it online at

== Features ==

use-nightly-features: (default: off, requires nightly) Enables the following functionality

- Specialization for trait impls
  For example, From<&[T]> where T is Copy can be optimized as a ptr::copy.
  We can specialize that case, while still allowing From<&[T]> for the
  types that only implement Clone.

- Adds the option to not specify a capacity for the stack buffer, which
  will default to the maximun capacity that fits in the RawVec's space.
  This default size causes no memory waste when switching to the heap.

alloc: (default: on) Links with the alloc crate. It is enabled by default, but it can be disabled for enviroments without alloc. If alloc is disabled, the vector/string will panic when it attempts to resize beyond it's stack-allocated space.

std: (default: on) Links with the std crate. This provides implementation of std::io::Write for TinyVec

serde: (default: off) Implements serde::Serialize and serde::Deserialize for TinyVec and TinyString

== Contributing == You can send patches to [email protected], or a pull request on the github mirror for this repo https://github.com/saulvaldelvira/tiny-vec

==== Copyright (C) 2025 Saúl Valdelvira

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3.

Dependencies

~165KB