Stack-allocated dynamically-sized types
This crate provides a simple way of returnings DSTs up to a certain size without requiring a heap allocation.
The core type is StackDST<Trait>
, which represents a fixed-capacity allocation of an unsized type.
The new
method on this type allows creating a instance from a concrete type, returning None
if the instance is too large
for the allocated region.
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 saved to a StackDST
```rust
use stack_dst::StackDST;
fn makeclosure(value: u64) -> StackDST