An Open Source Rust Developer!
I like contributing to open source Rust projects. I take away a lot from my open source experiences, so I tend to use this site to jot down what I understood from specific contributions. :)
Markdown supported · ⌘↵ to post
Two Wang
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:
&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.
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.