[][src]Crate tinyvec

Programmers can have a little vec, as a treat.

What This Is

This crate has two main types

  • ArrayishVec: Like the ArrayVec from the arrayvec crate. It's an array backed linear data store. If you push too much data it will panic.
  • TinyVec: NOT YET IMPLEMENTED. PLANNED FOR 0.2, SOON(TM) This will be like the SmallVec from smallvec. It starts as an ArrayishVec, and when that would have overflowed it will instead transition everything into a normal Vec on the heap.

How Is This Different From Those Other Crates?

It's 100% safe code. Not just "we think this unsafe code is sound so we'll give you a safe abstraction". This crate doesn't have a single unsafe block in it. If you trust the standard library to not trigger UB, then you can trust this crate to do the same.

The trade off is that the item type has to implement Default, and then the "spare space" of the vec is kept as Default instances of the type in question, rather than being uninitialized memory.

I haven't benchmarked it, but I suspect that there is a performance loss compared to just using unsafe and MaybeUninit and all that. I mean the code probably isn't the best it could possibly by, but also even if it were perfectly optimal I suspect that there will still be a performance hit compared to not using MaybeUninit. That's why we got it into the language after all.

Still, if you really want to be sure that there's no UB going on in your collection, here you are.

Macros

arr_vec

Helper to make an ArrayishVec.

tiny_vec

Structs

ArrayishVec

An array-backed vector-like data structure.

ArrayishVecDrain

Draining iterator for ArrayishVecDrain

ArrayishVecIterator

Iterator for consuming an ArrayishVec and returning owned elements.

TinyVecDrain

Draining iterator for TinyVecDrain

Enums

TinyVec
TinyVecIterator

Iterator for consuming an TinyVec and returning owned elements.

Traits

Arrayish

A trait for types that can be the backing store of an ArrayishVec.