InplaceBox
InplaceBox is a Rust library that provides a stack-allocated container similar to Box, but without heap allocation. It stores data inline within a fixed-size buffer.
Features
- Store values on the stack without heap allocation
- Support for dynamically sized types (like trait objects)
- Similar interface to
BoxwithDerefandDerefMutimplementations
Usage
use InplaceBox;
;
Requirements
This crate requires the nightly Rust compiler as it uses the following unstable features:
generic_const_exprsptr_metadataunsizecoerce_unsized
How It Works
InplaceBox uses Rust's advanced type system features to:
- Store the data in a fixed-size inline buffer
- Store vtable metadata for trait objects
- Implement smart pointer traits for seamless usage
It's ideal for embedded systems, performance-critical code, or situations where heap allocations should be avoided.
License
MIT
Contributions
Contributions are welcome! Please feel free to submit a Pull Request.