#dst #string #stack #string-parser

str_stack

A string allocator for allocating many write-once strings. This library is primarily useful for parsing where you need to repeatedly build many strings, use them, and then throw them away. Instead of allocating many independent strings, this library will put them all in the same buffer.

1 unstable release

Uses old Rust 2015

0.1.0 Nov 14, 2015

#1892 in Rust patterns

Download history 60450/week @ 2024-07-21 57955/week @ 2024-07-28 60095/week @ 2024-08-04 62526/week @ 2024-08-11 61040/week @ 2024-08-18 61076/week @ 2024-08-25 62983/week @ 2024-09-01 67213/week @ 2024-09-08 65031/week @ 2024-09-15 66488/week @ 2024-09-22 71140/week @ 2024-09-29 77416/week @ 2024-10-06 69279/week @ 2024-10-13 77351/week @ 2024-10-20 73452/week @ 2024-10-27 74097/week @ 2024-11-03

298,816 downloads per month
Used in 267 crates (2 directly)

MIT/Apache

11KB
255 lines

StrStack

Linux: Build Status

A string allocation library. This is primarily useful when you want to allocate a bunch of small strings, use them, and then destroy them all together.

Documentation

https://stebalien.github.com/str_stack/str_stack/

Performance

  • 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)

lib.rs:

A string allocation library. This is primarily useful when you want to allocate a bunch of small strings, use them, and then destroy them all together.

Example

use str_stack::StrStack;

let mut stack = StrStack::new();
let first = stack.push("one");
let second = stack.push("two");
let third = stack.push("three");

assert_eq!(&stack[first], "one");
assert_eq!(&stack[second], "two");
assert_eq!(&stack[third], "three");

No runtime deps