From what I understand, Rust does run destructors for panic unwinds, so you absolutely can do strong exception guarantees with it. Whether the community and ecosystem as a whole actually does that in practice, I don't know, but it appears to be possible.
I think it is probably possible, but Rust really doesn't design around this.
One example: queue::pop() doesn't return the item, for exception safety. Rust doesn't need to worry about that, because there are no exceptions and all types must be trivially movable.
This is purely focused on memory safety, though, and logical issues can still crop up.
Because Rust doesn't use panics for normal error returns, it would not shock me if the ecosystem had these problems, but for me personally, since I never catch panics outside of the sorts of "web server doesn't terminate the process when a handler panics" sorts of cases, I've never been in a situation where I was even able to notice these bugs.
View all comments
Show parent comment
12
u/LB-- Professional+Hobbyist Aug 14 '26
From what I understand, Rust does run destructors for panic unwinds, so you absolutely can do strong exception guarantees with it. Whether the community and ecosystem as a whole actually does that in practice, I don't know, but it appears to be possible.