I was contemplating what it would look like to provide this with a macro in Rust, and of course someone has already done it. It's syntactic sugar for the destructor/RAII approach.
https://docs.rs/defer-rs/latest/defer_rs/
I don't know Rust but, can this `defer` evaluate after the `return` statement is evaluated like in Swift? Because in Swift you can do this:
func atomic_get_and_inc() -> Int { sem.wait() defer { value += 1 sem.signal() } return value }
I don't know Rust but, can this `defer` evaluate after the `return` statement is evaluated like in Swift? Because in Swift you can do this: