Module str

Source
Expand description

Global, permanent, packed, hashconsed, short string storage.

  • supports strings up to 256 bytes
  • derefs to a &str, but uses only 1 word on the stack and len + 1 bytes on the heap
  • the actual bytes are stored packed into 1 MiB allocations to avoid the overhead of lots of small mallocs
  • Copy!
  • hashconsed, the same &str will always produce a pointer to the same memory

CAN NEVER BE DEALLOCATED

Structsยง

Str
This is either an immediate containing the string data, if the length is less than 8, or a pointer into static memory that holds the actual str slice if the data length is greater than 7.