tiny-vec

Crates.iotiny-vec
lib.rstiny-vec
version0.10.0
created_at2025-05-26 12:51:38.005407+00
updated_at2025-06-25 11:32:48.642565+00
descriptionSmall vector optimization
homepage
repositoryhttps://github.com/saulvaldelvira/tiny-vec
max_upload_size
id1689539
size119,874
Saúl (saulvaldelvira)

documentation

README

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 saul@saulv.es, 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.

Commit count: 64

cargo fmt