6 ms·
the tradeoff is that ~you have to guess where rust is doing the frees, and you might be wrong. in the end this would be strictly equivalent to an explicit inst
by throwawaymaths 1y ago
the tradeoff is that ~you have to guess where rust is doing the frees, and you might be wrong. in the end this would be strictly equivalent to an explicit instruction to free, with the compiler refusing to compile if the free location broke the rules.
It's really too bad rust went the RAII route.
- swiftcoder 1y agoThere's no guessing - Rust has well defined drop order. It also has manual drop, should you wish to override the defined order.
- throwawaymaths 1y agosorry i shouldn't have said guess. i meant consider
- whyever 1y agoHow often do you care about the order in which objects are dropped?
- throwawaymaths 1y agoanything where you need to have stuff run in constant time.
- mikepurvis 1y agoIf you're in hard realtime land then you can't have any allocations at all; that's a pretty different ballgame. Destructors should be as simple and side-effect free as possible, with the exception of things like locks or file handles where the expectation is very clear that the object going out of scope will trigger a release action.
- imtringued 1y agoOkay, but an IDE could just visualize that for you. A linter rule could force you to manually drop if you want to be explicit.