Skip to main content

Crate heap_drop

Crate heap_drop 

Source
Expand description

Provides a way of deallocating a value using a heap-allocated queue to traverse fields instead of stack recursion.

This effectively does nothing for types which implement Copy, e.g. integers. Such values are copied and then moved into the function, so the value persists after this function call.

§Examples

Basic usage:

use heap_drop::{HeapDrop, heap_drop};

#[derive(HeapDrop)]
struct Node(Option<Box<Node>>);

let v = Node(Some(Box::new(Node(None /* could be a very deep structure */))));
heap_drop(v);

Traits§

HeapDrop
A trait that allows a type to be disposed of using a heap-allocated queue instead of the stack.

Functions§

heap_drop
Disposes of a value using a heap-allocated queue to traverse fields instead of the stack.

Derive Macros§

HeapDrop
Derives the HeapDrop trait for a struct or enum, allowing it to be disposed of using a heap-allocated queue.