Module stack_str

Module stack_str 

Source
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.
  • Copy semantics 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.

PropertyASCIIUTF-8
Bytes per charAlways 11-4
36 bytes holds36 chars9-36 chars
Slice at any byteSafeMay split codepoint
len() == char countYesNo

Structs§

StackStr
A stack-allocated ASCII string with a maximum capacity of 36 characters.

Constants§

STACKSTR_CAPACITY
Maximum capacity in characters for a StackStr.