[][src]Crate smallvec

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 does not depend on std. However, the optional write feature implements the std::io::Write trait for vectors of u8. When this feature is enabled, smallvec depends on std.

Optional features

write

When this feature is enabled, SmallVec<[u8; _]> implements the std::io::Write trait. This feature is not compatible with #![no_std] programs.

union

This feature is unstable and requires a nightly build of the Rust toolchain.

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).

const_generics

This feature is unstable and requires a nightly build of the Rust toolchain.

When this feature is enabled, SmallVec works with any arrays of any size, not just a fixed list of sizes.

specialization

This feature is unstable and requires a nightly build of the Rust toolchain.

When this feature is enabled, SmallVec::from(slice) has improved performance for slices of Copy types. (Without this feature, you can use SmallVec::from_slice to get optimal performance for Copy types.)

may_dangle

This feature is unstable and requires a nightly build of the Rust toolchain.

This feature makes the Rust compiler less strict about use of vectors that contain borrowed references. For details, see the Rustonomicon.

Macros

smallvec

Creates a SmallVec containing the arguments.

Structs

Drain

An iterator that removes the items from a SmallVec and yields them by value.

IntoIter

An iterator that consumes a SmallVec and yields its items by value.

SmallVec

A Vec-like container that can store a small number of elements inline.

Enums

CollectionAllocErr

Error type for APIs with fallible heap allocation

Traits

Array

Types that can be used as the backing store for a SmallVec

ExtendFromSlice

Trait to be implemented by a collection that can be extended from a slice

ToSmallVec

Convenience trait for constructing a SmallVec