Stored page text, served from the archive.
Stored text only -- layout, images, and scripts from the original page are not preserved.
Lib .rs › Data structures # arrayvec # vec # no-std no-std tinyvec tinyvec provides 100% safe vec-like data structures by Lokathor and 48 contributors Audit Install API reference GitHub repo ( lokathor ) 42 releases (23 stable) 1.13.3 Sep 13, 2026 1.12.0 Jul 10, 2026 1.11.0 Mar 14, 2026 1.10.0 Aug 18, 2025 0.3.3 Mar 26, 2020 # 8 in Data structures 56,661,273 downloads per month Used in 35,389 crates (273 directly) Zlib OR Apache-2.0 OR MIT 180KB 4K SLoC tinyvec A 100% safe crate of vec-like types. Not just safe at the public API boundary, fully safe for all internal code too: #! [ forbid ( unsafe_code ) ] The provided types are as follows: ArrayVec is an array-backed vec-like data structure. It panics on overflow.
SliceVec is similar, but using a & mut [ T ] as the data backing. TinyVec ( alloc feature) is an enum that's either an Inline ( ArrayVec ) or a Heap ( Vec ) . If a TinyVec is Inline and would overflow its array it automatically transitions to Heap and continues whatever it was doing. To attain this "100% safe code" status there is one compromise: the element type of the vecs must implement Default .
For more API details, please see the docs.rs documentation tinyvec Alternatives? Maybe you don't want to use tinyvec , there's other crates you might use instead! arrayvec is a crate with array-backed structures. smallvec is a crate where the array-backed data can be moved to the heap on overflow.
The main difference is that both of those crates use unsafe code. This mostly allows them to get rid of the Default limitation for elements that tinyvec imposes. The smallvec and arrayvec crates are generally correct, but there's been occasional bugs leading to UB. With tinyvec , any uncaught bugs can't lead to UB, because the crate is safe code all the way through.
If you want that absolute level of assurance against UB, use tinyvec . Dependencies ~0–620KB ~13K SLoC optional arbitrary optional bin-proto optional borsh optional defmt optional generic-array 1.1 optional schemars 1.0 serde? serde_ core dev criterion 0.8 dev debugger_ test dev debugger_ test_ parser dev serde_ test dev smallvec Other features alloc debugger_visualizer experimental_write_impl grab_spare_slice latest_stable_rust nightly_slice_partition_dedup real_blackbox rustc_1_40 rustc_1_55 rustc_1_57 rustc_1_61 std tinyvec_macros Related: bytemuck_derive , bytemuck See also: arrayvec , smallvec , litemap , nunny , phf , criterion , itertools , either , fixedbitset , futures-intrusive , bit-set Lib.rs is an unofficial list of Rust/Cargo crates, created by kornelski . It contains data from multiple sources, including heuristics, and manually curated data .
Content of this page is not necessarily endorsed by the authors of the crate. This site is not affiliated with nor endorsed by the Rust Project. If something is missing or incorrect, please file a bug .