#compact #vector #strings #string


A cache-friendly but limited representation of a list of strings or bytestrings

5 releases (stable)

2.0.0 Sep 9, 2023
1.2.2 Jun 16, 2023
1.1.0 Jun 14, 2023
1.0.0 May 18, 2023
0.1.0 May 15, 2023

#709 in Rust patterns

Download history 36/week @ 2023-08-17 47/week @ 2023-08-24 24/week @ 2023-08-31 205/week @ 2023-09-07 87/week @ 2023-09-14 48/week @ 2023-09-21 37/week @ 2023-09-28 37/week @ 2023-10-05 29/week @ 2023-10-12 33/week @ 2023-10-19 40/week @ 2023-10-26 23/week @ 2023-11-02 26/week @ 2023-11-09 31/week @ 2023-11-16 41/week @ 2023-11-23 75/week @ 2023-11-30

175 downloads per month
Used in parui

MIT license

534 lines


A cache-friendly but limited representation of a list of strings.

Not affiliated with compact_str, this crate does not perform the same optimizations.


Strings are stored contiguously in a vector of bytes, with their lengths and starting indices being stored separately, rather than as a String struct holding a pointer to the data in Vec<String>.

This means that there are fewer pointers that need to be followed than in a Vec<String> which should lead to better cache locality, though this has yet to be tested.

Limitations include being unable to mutate strings stored in the vector.

This could be worked around with a limited API for mutation, but the cost of moving the rest of the bytes will be much higher than with a Vec<String>.


Some benchmarks of operations expected to perform vastly differently from a Vec<String> have been benchmarked, you can view them in here

No runtime deps