3 unstable releases
Uses old Rust 2015
0.5.1 | Jun 22, 2017 |
---|---|
0.5.0 | Jun 19, 2017 |
0.4.0 | Jun 12, 2017 |
#2201 in Data structures
9KB
224 lines
One-Stack-Vec
Overview
OneStackVec is simple data structure which contains any number of items. It does not heap allocation until there is one or zero item.
How to use
// Initialize
let mut items = OneStackVec::new();
// Adding
items.add(42);
// Getting
assert_eq!(Some(&42), items.get(0));
// Removing
assert_eq!(Some(&42), items.remove(0));
assert_eq!(None, items.get(0));
lib.rs
:
OneStackVec is simple data structure which contains any number of items. If there is one or zero item, ALO does not heap allocate. If there is more than one items, ALO does heap allocate.
Examples
use one_stack_vec::OneStackVec;
let mut items = OneStackVec::new();
// Adding
items.push(42);
// Getting
assert_eq!(Some(&42), items.get(0));
// Removing
assert_eq!(Some(42), items.pop());
assert_eq!(None, items.pop());
Dependencies
~110–350KB