parent
f043a949c5
commit
d14f9ad40a
@ -1,9 +1,10 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "stack-vec"
|
name = "stack-vec"
|
||||||
|
description = "Ad-hoc compile-time sized `Vec<T>` like types on the stack"
|
||||||
|
keywords = ["vec", "stack", "macro"]
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Avril <flanchan@cumallover.me>"]
|
authors = ["Avril <flanchan@cumallover.me>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
license = "MIT"
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
@ -0,0 +1,26 @@
|
|||||||
|
# stack-vec - Ad-hoc stack vectors
|
||||||
|
|
||||||
|
This crate defines the macro `stack![]`, which can be used to create ad-hoc `Vec<T>` like structs of a specific compile-time size on the stack.
|
||||||
|
|
||||||
|
These structs never allocate on the heap, and expose an API similar to `Vec<T>`.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
The macro can be used like `vec!`, with optional type inference.
|
||||||
|
|
||||||
|
``` rust
|
||||||
|
let sv = stack![100]; // Implicitly typed. Will cause a type inference error if the compiler cannot find the type of `sv` later.
|
||||||
|
let sv = stack![usize; 100]; // Explicitly typed, circumvents that error.
|
||||||
|
```
|
||||||
|
|
||||||
|
To see documentation of the types themselves, see one of the pre-defined `StackVec` types in the crate's root.
|
||||||
|
|
||||||
|
# Pre-defined types
|
||||||
|
`StackVec` types of powers of 2 up until 4096 are defined in this crate too.
|
||||||
|
You can use the macro to create your own named non-opaque `StackVec` types as well.
|
||||||
|
``` rust
|
||||||
|
stack!(pub type S10Elements S10IntoIter 10); // A `StackVec` type with a capacity of 10.
|
||||||
|
```
|
||||||
|
|
||||||
|
# License
|
||||||
|
MIT
|
||||||
|
|
Loading…
Reference in new issue