#stack #vec #small-vec #no-std #small #vector

no-std smallvec-stableunion

Fork of the crate smallvec. Uses unions in stable rust. Please note that it can only store Copy types. No functional differences apart from that.

1 unstable release

Uses old Rust 2015

0.6.10 Oct 5, 2019

#15 in #small-vec

23 downloads per month
Used in plain-map

MIT/Apache

68KB
1.5K SLoC

rust-smallvec

Documentation

Release notes

"Small vector" optimization for Rust: store up to a small number of items on the stack


lib.rs:

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.

no_std support

By default, smallvec depends on libstd. However, it can be configured to use the unstable liballoc API instead, for use on platforms that have liballoc but not libstd. This configuration is currently unstable and is not guaranteed to work on all versions of Rust.

To depend on smallvec without libstd, use default-features = false in the smallvec section of Cargo.toml to disable its "std" feature.

union feature

When the union feature is enabled smallvec will track its state (inline or spilled) without the use of an enum tag, reducing the size of the smallvec by one machine word. This means that there is potentially no space overhead compared to Vec. Note that smallvec can still be larger than Vec if the inline buffer is larger than two machine words.

To use this feature add features = ["union"] in the smallvec section of Cargo.toml. Note that this feature requires a nightly compiler (for now).

Dependencies

~170KB