Not quite. Destructors aren't guaranteed to run, so you can't actually rely on them for memory safety guarantees.
For example, leaking data in Rust is a perfectly safe thing to do. But while destructors help to prevent it, they cannot guarantee that nothing ever leaks. (And some of this depends on what you mean by "leaking" and so on.)
use-after-free, double-free and dangling pointers are all handled by Rust's ownership and borrowing systems.
For example, leaking data in Rust is a perfectly safe thing to do. But while destructors help to prevent it, they cannot guarantee that nothing ever leaks. (And some of this depends on what you mean by "leaking" and so on.)
use-after-free, double-free and dangling pointers are all handled by Rust's ownership and borrowing systems.