Inline (aka stack-allocated) dynamically-sized types, and collections of dyanmically-sized types using the same logic
This crate provides ways of storing DSTs directly within an allocation.
This crate covers two primary usecases
- Value
allows storing (and returning) a single DST within a fixed-size allocation
- Stack
and Fifo
allow heterogeneous collections without needing to box each object.
One of the most obvious uses is to allow returning capturing closures without having to box them. In the example below, the closure
takes ownership of value
, and is then returned using a Value
```rust
use stack_dst::Value;
// The closure is stored in two 64-bit integers (one for the vtable, the other for the value)
fn makeclosure(value: u64) -> Value
MaybeUninit
, so requires at least 1.36Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.