11 releases

0.5.0 Sep 22, 2024
0.4.0 Sep 19, 2021
0.3.1 Jul 10, 2021
0.2.3 Feb 22, 2021
0.1.3 Nov 24, 2020

#581 in Data structures

Download history 326/week @ 2024-08-20 258/week @ 2024-08-27 315/week @ 2024-09-03 469/week @ 2024-09-10 234/week @ 2024-09-17 396/week @ 2024-09-24 37/week @ 2024-10-01 279/week @ 2024-10-08 297/week @ 2024-10-15 152/week @ 2024-10-22 144/week @ 2024-10-29 393/week @ 2024-11-05 239/week @ 2024-11-12 328/week @ 2024-11-19 176/week @ 2024-11-26 207/week @ 2024-12-03

999 downloads per month
Used in 3 crates

BSL-1.0 license

95KB
2K SLoC

MiniVec

std::vec::Vec is a cool class but it's just too big! MiniVec is only the size of a pointer.

Acknowledgements

This library is dedicated to the great Glen Joseph Fernandes whose constant tutelage has been instrumental in making me the programmer that I am.

We would also like to thank the following for their contributions:

Why use an alternative to std::vec::Vec?

It's an interesting choice to replace a container as ubiquitous as Vec with an alternative implementation.

For that reason, it's not a wise design choice to use MiniVec itself in public interfaces as it'll create friction with the rest of the ecosystem. Instead, MiniVec is ideal for internal implementation details.

Its smaller size penalizes users less for using it as a data member and it can expose some Nightly Vec APIs in a stable way. It also contains myriad extensions to the standard Vec interface and the project aims to be community-driven, i.e. any feature a user wants, they're likely to have their PR merged.

To be competetive performance-wise with the standard library, we must use several currently Nightly features. Namely, specialization and access to other intrinsics. To compile MiniVec with such optimizations, one must use:

cargo +nightly build --features minivec_nightly

Serde is similarly supported via:

cargo build --features serde

Dependencies

~160KB