| Crates.io | inplace-box |
| lib.rs | inplace-box |
| version | 0.2.1 |
| created_at | 2025-07-18 09:53:19.844647+00 |
| updated_at | 2025-07-28 08:50:46.676237+00 |
| description | A stack-allocated container similar to Box but without heap allocation |
| homepage | https://github.com/drmingdrmer/inplace-box |
| repository | https://github.com/drmingdrmer/inplace-box |
| max_upload_size | |
| id | 1758810 |
| size | 41,435 |
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.
Box with Deref and DerefMut implementationsuse inplace_box::InplaceBox;
trait MyTrait {
fn method(&self) -> i32;
}
struct MyStruct(i32);
impl MyTrait for MyStruct {
fn method(&self) -> i32 {
self.0
}
}
fn main() {
let inplace_box = InplaceBox::<dyn MyTrait>::new(MyStruct(42));
assert_eq!(inplace_box.method(), 42);
}
This crate requires the nightly Rust compiler as it uses the following unstable features:
generic_const_exprsptr_metadataunsizecoerce_unsizedInplaceBox uses Rust's advanced type system features to:
It's ideal for embedded systems, performance-critical code, or situations where heap allocations should be avoided.
MIT
Contributions are welcome! Please feel free to submit a Pull Request.