packed_str

Crates.iopacked_str
lib.rspacked_str
version0.2.1
sourcesrc
created_at2023-07-10 04:03:12.456201
updated_at2023-07-10 05:52:48.046114
descriptionStore immutable strings in a single packed allocation
homepage
repositoryhttps://github.com/ericseppanen/packed_str
max_upload_size
id912522
size12,031
Eric Seppanen (ericseppanen)

documentation

README

Packed Immutable Strings

PackedStr is a replacement for Vec<String> when the strings are all immutable.

The benefit of using PackedStr is that all of the string data is stored in a single heap allocation. This may save space compared to Vec<String>, where each String has its own heap allocation, and associated costs (excess String capacity, allocator metadata, heap fragmentation).

In addition, each String stores its own size and capacity, which are not necessary due to the PackedStr design.

PackedStr is implemented as one large buffer containing all the string data, and a list of indexes into the buffer. Each string slice can be reconstructed from its index, and the index of the next string (or the end of the buffer, for the last string).

Commit count: 7

cargo fmt