This repo tries to assess Rust string types.
We currently compare:
| Name | Size | Heap | Inline | &'static str | Mutable | Unsafe | Notes |
|---|---|---|---|---|---|---|---|
String | 24 bytes | Y | - | N | Y | - | Universal |
Cow<'static, str> | 24 bytes | Y | - | Y | N | - | |
arcstr | 8 bytes | ? | ? | ? | ? | ? | ? |
cold-string | 8 bytes | Y | 8 bytes | N | N | Y (miri, proptest) | Space optimized for non-inline strings, 1 byte aligned (1 byte extra for Option<_>) |
compact_str | 24 bytes | Y | 24 bytes | Y | Y | Y (miri, proptest, fuzz) | Space optimized for Option<_> |
ecow | 16 bytes | Y | 15 bytes | N | Y | Y (miri) | O(1) clone unless mutated, Space optimized for Option<_> |
flexstr | 24 bytes | Y | 22 bytes | Y | N | Y (miri) | O(1) clone |
hipstr | 24 bytes | Y | 23 bytes | Y | Y | Y (miri) | O(1) clone, O(1) substring |
imstr | 24 bytes | ? | ? | ? | ? | ? | ? |
kstring | 24 bytes | Y | 15 bytes | Y | N | Optional (miri, proptest) | Optional O(1) clone, optional 22 byte small string, Ref/Cow API for preserving &'static str |
lean_string | 16 bytes | Y | 16 bytes | Y | Y | Y (miri, proptest) | O(1) clone unless mutated, Space optimized for Option<_> |
smartstring | 24 bytes | Y | 23 bytes | N | Y | Y (miri, proptest, fuzz) |
Suggestions:
StringCow<'static, str>Note: smol_str was removed in favor of ecow
Terms:
See more details
See more details
(smartstring is skipped due to how slow it is)
See more details
See more details
HTML
99.3%
This repo tries to assess Rust string types.
We currently compare:
| Name | Size | Heap | Inline | &'static str | Mutable | Unsafe | Notes |
|---|---|---|---|---|---|---|---|
String | 24 bytes | Y | - | N | Y | - | Universal |
Cow<'static, str> | 24 bytes | Y | - | Y | N | - | |
arcstr | 8 bytes | ? | ? | ? | ? | ? | ? |
cold-string | 8 bytes | Y | 8 bytes | N | N | Y (miri, proptest) | Space optimized for non-inline strings, 1 byte aligned (1 byte extra for Option<_>) |
compact_str | 24 bytes | Y | 24 bytes | Y | Y | Y (miri, proptest, fuzz) | Space optimized for Option<_> |
ecow | 16 bytes | Y | 15 bytes | N | Y | Y (miri) | O(1) clone unless mutated, Space optimized for Option<_> |
flexstr | 24 bytes | Y | 22 bytes | Y | N | Y (miri) | O(1) clone |
hipstr | 24 bytes | Y | 23 bytes | Y | Y | Y (miri) | O(1) clone, O(1) substring |
imstr | 24 bytes | ? | ? | ? | ? | ? | ? |
kstring | 24 bytes | Y | 15 bytes | Y | N | Optional (miri, proptest) | Optional O(1) clone, optional 22 byte small string, Ref/Cow API for preserving &'static str |
lean_string | 16 bytes | Y | 16 bytes | Y | Y | Y (miri, proptest) | O(1) clone unless mutated, Space optimized for Option<_> |
smartstring | 24 bytes | Y | 23 bytes | N | Y | Y (miri, proptest, fuzz) |
Suggestions:
StringCow<'static, str>Note: smol_str was removed in favor of ecow
Terms:
See more details
See more details
(smartstring is skipped due to how slow it is)
See more details
See more details
HTML
99.3%