dynstack

A stack for trait objects that minimizes allocations

1 unstable release

0.1.0 Nov 6, 2018

#6 in #trait-object

Download history 5/week @ 2018-11-06 8/week @ 2018-11-13 9/week @ 2018-11-20 2/week @ 2018-11-27 4/week @ 2018-12-04 2/week @ 2018-12-11 31/week @ 2018-12-18 34/week @ 2018-12-25

1 downloads per month

MIT license

10MB
371 lines

dynstack

A stack for trait objects that minimizes allocations

COMPATIBILITY NOTE: dynstack relies on an underspecified fat pointer representation. Though it isn't expected to change in the foreseeable future, this crate expects Rust 1.32's representation.

Usage

dynstack can mostly replace anywhere you'd use a stack, or a vector that doesn't require removal from its center.

let mut stack = DynStack::<Debug>::new();
dyn_push!(stack, "hello, world!");
dyn_push!(stack, 0usize);
dyn_push!(stack, [1, 2, 3, 4, 5, 6]);

for item in stack.iter() {
    println!("{:?}", item);
}

// prints:
//  "hello, world!"
//  0
//  [1, 2, 3, 4, 5, 6]

lib.rs:

dynstack can mostly replace anywhere you'd use a stack, or a vector that doesn't require removal from its center.

# use dynstack::{DynStack, dyn_push};
# use std::fmt::Debug;
let mut stack = DynStack::<Debug>::new();
dyn_push!(stack, "hello, world!");
dyn_push!(stack, 0usize);
dyn_push!(stack, [1, 2, 3, 4, 5, 6]);

for item in stack.iter() {
    println!("{:?}", item);
}

// prints:
//  "hello, world!"
//  0
//  [1, 2, 3, 4, 5, 6]

No runtime deps