A Rust implementation of Go's
defer statement as the
defer! macro, which executes a block of code when the surrounding scope ends.
This crate focuses on providing a lightweight, high-performance,
no_std implementation of the
Add the dependency in your
 = "1.0.0"
use defer; // import the defer! macro
In Go, the
defer code runs when the function exits. In this Rust implementation, the code runs when the surrounding scope ends – this makes it possible to use
defer inside loops: