Crates.io | thinarray |
lib.rs | thinarray |
version | 0.1.0 |
source | src |
created_at | 2024-08-24 07:39:55.094856 |
updated_at | 2024-08-24 07:39:55.094856 |
description | A thin alternative to Box<[T]> |
homepage | |
repository | |
max_upload_size | |
id | 1349922 |
size | 8,799 |
This is a thin array type, meant to be an alternative to Box<[T]>
when you have more arrays than actual data in them. It's only as big as one usize, and doesn't allocate for an empty array.
It stores the array length with the data, whereas Box<[T]>
stores it with the pointer. That helps with memory usage in many cases, with only the minor downside that accessing the length needs one more pointer indirection, unless it's 0. is_empty
avoids that indirection.