---
title: "Comment by Two Wang on \"Let's talk about unwind safety!\" | Hashnode"
description: "The framing that helped me most: UnwindSafe is a lint about observing broken invariants, not about memory safety. Rust still guarantees no UB when a panic unwin"
url: "https://hashnode.com/posts/let-s-talk-about-unwind-safety/6b03f0209be40ec5796ba371/comment/6b047c4533a57a177ba17081"
---

[Discussion](https://hashnode.com/posts/let-s-talk-about-unwind-safety/6b03f0209be40ec5796ba371)

Comment [Let's talk about unwind safety!](https://hashnode.com/posts/let-s-talk-about-unwind-safety/6b03f0209be40ec5796ba371)

[Two Wang](https://hashnode.com/@twowang59)

[Nov 23](https://hashnode.com/posts/let-s-talk-about-unwind-safety/6b03f0209be40ec5796ba371/comment/6b047c4533a57a177ba17081)

The framing that helped me most: UnwindSafe is a lint about observing broken invariants, not about memory safety. Rust still guarantees no UB when a panic unwinds through your code, so the trait exists to stop catch\_unwind from handing you back a value that was mid-update when the invariant broke.

Two practical consequences I keep running into:

1.  &mut T is deliberately not UnwindSafe. A panic halfway through a two-field invariant update leaves the struct memory-safe but not in the state your API promised, and the marker trait encodes exactly that.
    
2.  AssertUnwindSafe is usually right at the outer boundary of a fallible call (a plugin hook, a request handler) where the mutated state is discarded on panic anyway. It is usually wrong around a Vec you plan to keep using, because you are asserting the one thing you cannot prove.
    

The runtime version of the same idea is poisoning: Mutex poison and the RefCell borrow flag both record that a panic may have left things half-done, and the safe default is to refuse further access rather than optimistically continue.

[Mahdi Ali-Raihan](https://hashnode.com/@asder5124)

[Nov 23](https://hashnode.com/posts/let-s-talk-about-unwind-safety/6b03f0209be40ec5796ba371/comment/6b047c4533a57a177ba17081#reply-6b048a13506e513b77c18eac)

Thank you for the clear explanation of `UnwindSafe`!
