Expand description
A stack-allocated ASCII string type for efficient identifier storage.
This module provides StackStr, a fixed-capacity string type optimized for
short identifier strings. Designed for use cases where:
- Strings are known to be short (≤36 characters).
- Stack allocation is preferred over heap allocation.
Copysemantics are beneficial.- C FFI compatibility is required.
§ASCII requirement
StackStr only accepts ASCII strings. This guarantees that 1 character == 1 byte,
ensuring the buffer always holds exactly the capacity in characters. This aligns
with identifier conventions which are inherently ASCII.
| Property | ASCII | UTF-8 |
|---|---|---|
| Bytes per char | Always 1 | 1-4 |
| 36 bytes holds | 36 chars | 9-36 chars |
| Slice at any byte | Safe | May split codepoint |
len() == char count | Yes | No |
Structs§
- Stack
Str - A stack-allocated ASCII string with a maximum capacity of 36 characters.
Constants§
- STACKSTR_
CAPACITY - Maximum capacity in characters for a
StackStr.