You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A utility/language extension that I quite like and which seems to be fairly commonly used (looking at the numbers on crates.io) is scopeguard, which adds a helper function and convenience macro for deferred cleanup actions (similar to the defer statement in Go).
The text was updated successfully, but these errors were encountered:
28M recent downloads, so it qualifies as popular at least...
I ran into this recently but I'm honestly not much of a fan, feels more idiomatic (and not much more verbose) to just define a guard type with a Drop impl.
I guess it's a matter of taste. I personally like it because it allows me to have cleanup logic in the method body, close to the rest of the method code, rather than in a separate Drop impl. I find it more readable than the alternatives for cleanup logic that is specific to one method.
A utility/language extension that I quite like and which seems to be fairly commonly used (looking at the numbers on crates.io) is scopeguard, which adds a helper function and convenience macro for deferred cleanup actions (similar to the
defer
statement in Go).The text was updated successfully, but these errors were encountered: