MCPcopy Index your code
hub / github.com/Lokathor/tinyvec

github.com/Lokathor/tinyvec @v1.11.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.11.0 ↗ · + Follow
343 symbols 770 edges 23 files 16 documented · 5%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

License:Zlib Minimum Rust Version crates.io docs.rs

Unsafe-Zero-Percent

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.

Extension points exported contracts — how you extend this code

Array (Interface)
A trait for types that are an array. An "array", for our purposes, has the following properties: Owns some number of el [2 …
src/array.rs

Core symbols most depended-on inside this repo

push
called by 78
src/tinyvec.rs
clone
called by 71
src/tinyvec.rs
splice
called by 68
src/tinyvec.rs
len
called by 35
src/arrayvec.rs
iter
called by 35
src-backup/arrayset.rs
len
called by 24
src/tinyvec.rs
as_slice_mut
called by 23
src/array/generic_array_impl.rs
as_slice
called by 19
src/arrayvec.rs

Shape

Method 238
Function 81
Class 18
Enum 5
Interface 1

Languages

Rust100%

Modules by API surface

src/arrayvec.rs95 symbols
src/tinyvec.rs77 symbols
src/slicevec.rs56 symbols
tests/tinyvec.rs25 symbols
src-backup/arrayset.rs21 symbols
tests/arrayvec.rs19 symbols
src/arrayvec_drain.rs9 symbols
fuzz/src/bin/tinyvec_drain.rs5 symbols
fuzz/src/bin/slicevec.rs5 symbols
fuzz/src/bin/arrayvec_iter.rs5 symbols
fuzz/src/bin/arrayvec_drain.rs5 symbols
fuzz/src/arb_range.rs5 symbols

For agents

$ claude mcp add tinyvec \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact