Skip to main content

run_with_close_guards

Function run_with_close_guards 

Source
pub fn run_with_close_guards(
    cx: &mut Cx,
    guards: Vec<CloseGuard>,
    body: impl FnOnce(&mut Cx) -> Result<Value>,
) -> Result<Value>
Expand description

Runs body and closes all guards in reverse order before returning.

Each close function receives the guarded value and a pending-error argument. The pending-error argument is nil on a normal return, or a string representation of the body error when body fails. All guards are invoked even when an earlier guard reports an error. Body errors take precedence over close errors; otherwise the first close error is returned.