Expand description

A pointer type for dynamically allocated memory.

Similar to std::boxed::Box Box<T> is a pointer type that can deallocate memory when it goes out of scope.

This crate can also be used for pointer to statics because in contrast to pointers Box<T> cannot be copied and an accidental drop can be caught.

Note: in the current implementation the type is static, but de-/allocation will be added with a dynamic memory allocation feature. The type should work with pooled as well as heap allocators.

Examples

Allocating a data structure in a static pool will return a boxed pointer to the new value:

static POOL: ArrayPool<Node<MyStruct>, 10> = ArrayPool::new([None; 10]);
let boxed: Box<MyStruct> = POOL.insert(Node::new(MyStruct { id: 42 })).unwrap();

Structs

A pointer type for dynamically allocated memory.