#string #stack #dst

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

#2338 in Algorithms

Download history 43955/week @ 2023-12-06 42604/week @ 2023-12-13 29316/week @ 2023-12-20 25312/week @ 2023-12-27 42579/week @ 2024-01-03 45477/week @ 2024-01-10 51715/week @ 2024-01-17 46820/week @ 2024-01-24 44847/week @ 2024-01-31 43602/week @ 2024-02-07 44638/week @ 2024-02-14 51278/week @ 2024-02-21 51905/week @ 2024-02-28 50938/week @ 2024-03-06 49859/week @ 2024-03-13 46070/week @ 2024-03-20

209,469 downloads per month
Used in 210 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