trait
UnwindSafe — crossing a panic boundary
A marker used by catch_unwind to flag state that may expose a broken invariant after a panic. It is not a transactional guarantee or an unsafe trait. A closure capturing mutable references may fail the bound. Expected stdout (not executed): 6 Common mistake: Treating the bound as proof of business-state consistency.
Formal Syntax & Structure
rust syntaxrust
pub auto trait UnwindSafe {}Working Example
Example Snippetrust
fn main() { let count = 5; println!("{}", std::panic::catch_unwind(|| count + 1).unwrap());}