nested
A memory efficient container for nested collections.
This crate is intended to be used when:
- you want a potentially large:
Vec<String>
Vec<Vec<T>>
Vec<C>
whereC
is heap allocated, dynamically sized and can implementCollection
trait
- you actually only need to use borrowed items (
&[T]
or&str
)
Instead of having n + 1 allocations, you'll only have 2.
Example
use Nested;
let mut v = new;
// you can either populate it one by one
v.push;
v.push;
v.push;
v.extend;
assert_eq!;
assert_eq!;
assert_eq!;
// or you can directly collect it
let mut v = .iter.;
assert_eq!;
// it also provides basic operations
let u = v.split_off;
assert_eq!;
v.truncate;
assert_eq!;
assert_eq!;
Benches
See benches directory.
Here are the benches for collecting all words in src/lib.rs file:
test bench_nested_string ... bench: 55,381 ns/iter (+/- 7,852)
test bench_nested_string_iter ... bench: 95,127 ns/iter (+/- 8,253)
test bench_vec_string ... bench: 117,203 ns/iter (+/- 13,089)
test bench_vec_string_iter ... bench: 142,245 ns/iter (+/- 24,701)
Licence
MIT