This is the simplest and the fastest implementation of a stack data structure, on stack.
First, add this to Cargo.toml
:
toml
[dependencies]
microstack = "0.0.3"
Then, use it like this:
rust
use microstack::Stack;
let mut s : Stack<&str, 10> = Stack::new(); // allocation on stack
s.push("foo");
s.push("bar");
assert_eq!("bar", *s.pop().unwrap());
assert_eq!(1, s.len());
Pay attention, here the stack is created with an extra generic argument 10
. This is
the total size of the stack, which is allocated on stack when ::new()
is called.
Read the API documentation.
First, install Rust and then:
bash
$ cargo test -vv
If everything goes well, fork repository, make changes, send us a pull request.
We will review your changes and apply them to the master
branch shortly,
provided they don't violate our quality standards. To avoid frustration,
before sending us your pull request please run cargo test
again. Also,
run cargo fmt
and cargo clippy
.
Also, before you start making changes, run benchmarks:
bash
$ rustup run nightly cargo bench
Then, after the changes you make, run it again. Compare the results. If your changes degrade performance, think twice before submitting a pull request.