Kind of with Rust had a notion of `impl TryDrop` for running destructors that can be unsuccessful. Could handle errors gracefully in Result contexts. Call `.unwrap()` in other contexts. Manually dropping through `try_drop(my_fn())?;`
Hmm, what if you have two instances of Foo, and the cleanup method errors halfway through? Drop would still be called right. But all other instances of .cleanup() would not. Might potentially leak?
-
-
right, you still need to implement the Drop method. It would be nice if we could have a Cleanup trait that implies a Drop impl, but that's not easy to make work in Rust's type system because Drop is weird
-
it will only leak if your cleanup() and Drop impls don't do similar things.
End of conversation
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.