Function stacker::maybe_grow [] [src]

pub fn maybe_grow<R, F: FnOnce() -> R>(
    red_zone: usize,
    stack_size: usize,
    f: F
) -> R

Grows the call stack if necessary.

This function is intended to be called at manually instrumented points in a program where recursion is known to happen quite a bit. This function will check to see if we're within red_zone bytes of the end of the stack, and if so it will allocate a new stack of size stack_size.

The closure f is guaranteed to run on a stack with at least red_zone bytes, and it will be run on the current stack if there's space available.