Man, I wish Rust had the 'defer' keyword 😞
Wait...
🦀 **scopeguard**: A Rust library for a convenient RAII scope guard.
🌀 Has a defer! macro.
🔥 Runs a closure on scope exit, even if a panic occurs.
⭐ GitHub: github.com/bluss/scopeguard
#rustlang #library #defer #scope #raii #guard #programming #pattern #opensource
GitHub - bluss/scopeguard: Rust crate for a convenient RAII scope guard.
Rust crate for a convenient RAII scope guard. Contribute to bluss/scopeguard development by creating an account on GitHub.GitHub
ede1998
in reply to Orhun Parmaksız 👾 • • •this is less useful in Rust though because of borrow checker. You need interior mutability to really make use of that because you cannot call any method that takes ownership/mutable references in either defer or the normal scope.
Unless you write a proc macro wrapping the entire function that rewrites all exit points (including panics) to include the deferred action?