#vec #safe #array-vec #inline #structures #enums

no-std tinyvec

tinyvec provides 100% safe vec-like data structures

30 releases (11 stable)

1.6.0 Apr 25, 2022
1.5.1 Nov 9, 2021
1.5.0 Sep 25, 2021
1.3.1 Jul 22, 2021
0.3.3 Mar 26, 2020

#30 in Data structures

Download history 1393640/week @ 2024-01-02 1453466/week @ 2024-01-09 1577776/week @ 2024-01-16 1520950/week @ 2024-01-23 1663841/week @ 2024-01-30 1618747/week @ 2024-02-06 1571148/week @ 2024-02-13 1660877/week @ 2024-02-20 1740767/week @ 2024-02-27 1719954/week @ 2024-03-05 1710158/week @ 2024-03-12 1776643/week @ 2024-03-19 1692282/week @ 2024-03-26 1904932/week @ 2024-04-02 1774201/week @ 2024-04-09 1480415/week @ 2024-04-16

7,173,411 downloads per month
Used in 27,826 crates (128 directly)

Zlib OR Apache-2.0 OR MIT

345KB
13K SLoC

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

Unsafe-Zero-Percent

tinyvec

A 100% safe crate of vec-like types. #![forbid(unsafe_code)]

Main types are as follows:

  • ArrayVec is an array-backed vec-like data structure. It panics on overflow.
  • SliceVec is the same deal, but using a &mut [T].
  • TinyVec (alloc feature) is an enum that's either an Inline(ArrayVec) or a Heap(Vec). If a TinyVec is Inline and would overflow 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 details, please see the docs.rs documentation

Dependencies

~200KB