[][src]Macro flowutils::defer

defer!() { /* proc-macro */ }

Golang's defer in Rust.

  • This is scoped. A deferred action is performed at the end of the scope, not the end of the function.
  • Multiple defer!s are executed in the reverse order.

Example:

flowutils::defer!(println!("order 6"));
{
    flowutils::defer!(println!("order 4"));
    flowutils::defer!({
        println!("order 2");
        println!("order 3");
    });
    flowutils::defer!(println!("order 1"));
}
flowutils::defer!(println!("order 5"));