Skip to main content

ensure_sufficient_stack

Function ensure_sufficient_stack 

Source
pub fn ensure_sufficient_stack<R>(f: impl FnOnce() -> R) -> R
Expand description

Run f, first moving to a fresh stack segment if the current stack is close to exhausted.

Call this where a recursive pass descends one level — the point whose repetition is bounded by input nesting depth rather than by the code. Adding it to a leaf helper only costs a check; omitting it from a recursion step is what reintroduces the abort.