Crate small_fixed_array
source ·Expand description
A crate for FixedArray and FixedString, types to provide a smaller memory footprint in exchange for:
- Immutablity,
FixedArrayandFixedStringcannot be mutated without converting back to their expanded forms. - Maximum length,
FixedArrayandFixedStringhave a length cap ofLenT::MAXelements.
These types provide cheap conversions to Vec and String, to make up for most of these downsides, but it is
still not recommended to use these collections for mutated values as you will see a performance downside.
These can be thought of as Box<[T]> and Box<str>, except the length is denoted as LenT, by default u32.
Features
serde: Providesserdeimplementations forFixedArrayandFixedString.typesize: Providestypesizeimplementations forFixedArrayandFixedString.
From implementations
From<Vec<T>>forFixedArray and From<String>forFixedString are only implemented if one of
log_using_log or log_using_tracing are enabled, as the implementations will error level log
if the Vec/String’s length is too high for the provided LenT generic.
Structs
- A fixed size array with length provided at creation denoted in a
ValidLength, by defaultu32. - A fixed size String with length provided at creation denoted in
ValidLength, by defaultu32.
Traits
- A sealed trait to represent valid lengths for a
FixedArray.