XIO

xArchive

Stored page text, served from the archive.

SmallVec — data structures in Rust // Lib.rs

Archived: 2026-11-07 02:17:03 UTC View live page ↗
https://lib.rs/crates/smallvec

Stored text only -- layout, images, and scripts from the original page are not preserved.

Lib .rs › Data structures # stack # vec # no-std no-std smallvec 'Small vector' optimization: store up to a small number of items on the stack by The Servo Project Developers ( 3 contributors ). Owned by Ms2ger , Simon Sapin , Servo , alejandro-vaz . Audit Install API reference Source Repository link ( …/… ) Home (smallvec.rs) 68 releases (31 stable) Uses new Rust 2024 2.0.0-beta.4 Oct 30, 2026 2.0.0-beta.1 Sep 20, 2026 2.0.0-alpha.12 Nov 16, 2025 2.0.0-alpha.11 Mar 20, 2025 0.1.5 Jun 30, 2015 # 3 in Data structures 136,964,433 downloads per month Used in 153,909 crates (4,527 directly) MIT/Apache 160KB 3.5K SLoC rust-smallvec Warning smallvec v2 is on pre-release this means that there might be unexpected changes between versions. see the changelog for detailed breakdowns changes include, but are not limited to: breaking API changes deprecation of items adding, removing or modifying features beware that this is a pre-release and we can't ensure that there are no vulnerabilities or corner cases.

if this feels like a substantial risk to you, please downgrade to the latest v1 version we are looking for people to test this v2 version, so feel free to play around with smallvec and use it for your purposes if this warning is not a concern, and please file an issue on the repo if you find some unexpected behavior or have a request for a feature Release notes Small vectors in various sizes. These store a certain number of elements inline, and fall back to the heap for larger allocations. This can be a useful optimization for improving cache locality and reducing allocator traffic for workloads that fit within the inline buffer. Example use smallvec::SmallVec; // This SmallVec can hold up to 4 items on the stack: let mut v: SmallVec<i32, 4> = SmallVec::from([1, 2, 3, 4]); // It will automatically move its contents to the heap if // contains more than four items: v.push(5); // SmallVec points to a slice, so you can use normal slice // indexing and other methods to access its contents: v[0] = v[1] + v[2]; v.sort(); Feature List allocator-api (nightly): uses the allocator-api backend for the allocator API allocator-api2 : uses the allocator-api2 backend for the allocator API arbitrary : implements Arbitrary for any SmallVec storing elements that implement Arbitrary borsh : implements BorshSerialize , BorshDeserialize and BorshSchema bytes : implements BufMut for SmallVec defmt : implements defmt :: Format for SmallVec encase : implements encasing as a runtime-sized array equivalent : implements equivalent :: Equivalent for SmallVec internals : exports through the public API LocatedLength and RawSmallVec malloc_size_of : implements MallocSizeOf and MallocShallowSizeOf rayon : implements parallel iteration serde : implements serde's serialization and deserialization specialization (nightly): enables specialization, improving performance on some cases std : implements the std :: io :: Write type for SmallVec < u8 , INLINE > zeroize : implements zeroize :: Zeroize , erasing elements and storage Note SmallVec without any features enabled does not make use of the standard library.

The rayon and proptest features implicitly require std . The allocator-api2 feature requires allocator-api , though it does not require nightly Dependencies ~0–2.1MB ~44K SLoC optional allocator-api2 0.4 + alloc optional arbitrary optional borsh + derive + unstable__schema optional bytemuck optional bytes optional defmt optional encase 0.13 optional equivalent malloc-size-of? malloc_ size_ of optional proptest + std optional rayon optional rkyv 0.8 + alloc optional schemars 1.0 serde? serde_ core smallvec-macro optional zeroize dev criterion 0.8 dev iai-callgrind dev serde_ test Other features allocator-api internals may-dangle specialization std See also: arrayvec , range-collections , small-map , range-set , smallvec-wrapper , bumpalo , hashbrown , indexmap , phf , itertools , tinyvec 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 .