str_stack is a string allocation library for allocating many temporally correlated write-once strings. This is useful when you need to e.g. read a set of small files into strings but don't want to allocate a new string per file. Additionally, this library provides great cache locality.
Currently, the performance (on my laptop) is as follows:
Allocation: ~2.5x speedup (for 1000 strings) (~42ns per string)
Indexing: 0.73x speedup (slower) (~1.7ns per index)
Iterate: 0.35x speedup (much slower) (~1ns per iteration)
It should be possible to further speedup allocation (see the open issue) but speeding up indexing/iteration are beyond me.
I'll put it on crates.io if people find it useful but, for now, I don't even know if this is the right approach.
You're the first one I see to use the ducktypiness of the write!() macro, and that explains why I was so confused when I saw it used on a string stack. It's a cute experiment, only experience will tell if it's a good idea.
You can use format_args!() to do kind of the same thing without punning the write_fmt method name. Maybe that's just as cryptic though: