stack_dst
Inline (aka stack-allocated) dynamically-sized types
Overview
This crate provides ways of storing DSTs inline (not needing a heap allocation)
Basic usage
This crate covers two primary usecases
Value
allows storing (and returning) a single DST within a fixed-size allocation.Stack
andFifo
allow heterogeneous collections without needing to box each object.
Example
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
use Value;
let closure = make_closure;
assert_eq!;
Status
- Works for most test cases
- Not rigourously tested across platforms
Minimum rust version
- Uses
MaybeUninit
, so requires at least 1.36
License
Licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
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.