funfun 0.1.0

Macro for allocating closures to the heap.
Documentation

funfun

Build Status Coveralls Coverage Status Codecov Coverage Status Crates.io

heap_fn!

macro for allocating closures to the heap. Heap-allocated closures can be convenient when (re)assigning closures to structure fields, though heap allocation comes at the expense of inline optimization.

Usage:

let closure = heap_fn!(
    || {
        println!("This closure lives in the heap now!")
    }
);

closure.c()(); // "This closure lives in the heap now!"

let closure_identifier = || {println!("Named closure!")};

heap_fn!(closure_identifier).c()(); // "Named closure!"