Skip to content
Better HN
Top
New
Best
Ask
Show
Jobs
Search
⌘K
undefined | Better HN
0 points
panic
8y ago
0 comments
Share
You could use something like Go's 'defer' statement to ensure 'close' is called before the current function returns.
0 comments
default
newest
oldest
belovedeagle
8y ago
Which already exists in Rust in the form of... wait for it... the Drop trait. It's the same thing.
matt_kantor
8y ago
The difference is that Go's `defer` is explicitly written out in the relevant scope, while Rust's `Drop` is implicit and defined elsewhere.
steveklabnik
8y ago
There's a "scopeguard" crate that uses Drop to make it explicit.
j
/
k
navigate · click thread line to collapse