Short answer:
- most likely use in
panic!()almost all cases - you can pretty much make sure no destructors are left if ...
- ... you are in function
main() - ... you manually process the stack, including unwinding (you probably don't ...)
- sometimes you can just ignore the destructors when you exit the program anyway, but you need to be careful!
A little longer explanation
[...] for small tools seems convenient.
If you want to exit your program due to a fatal error, we recommend using panic!(). This will spin up the stack (start all destructors) and exit the program with additional information (including the message line that you can specify).
[...], , , .
, , , Drop . - , ( ). , , Drop.
, - , (" main() ). , main().
Drop? , . i32: , , ( ). , Drop. :
- :
Box<T>, Vec<T>, HashMap<T>,... - :
File, Socket,... - :
Ref, MutexGuard,... - ...
, . , , : . , . : .
. : , Drop, . , . , .