diff --git a/src/error-handling/panic-unwind.md b/src/error-handling/panic-unwind.md index beada987..2f5213e5 100644 --- a/src/error-handling/panic-unwind.md +++ b/src/error-handling/panic-unwind.md @@ -5,15 +5,17 @@ By default, a panic will cause the stack to unwind. The unwinding can be caught: ```rust,editable use std::panic; -let result = panic::catch_unwind(|| { - println!("hello!"); -}); -assert!(result.is_ok()); - -let result = panic::catch_unwind(|| { - panic!("oh no!"); -}); -assert!(result.is_err()); +fn main() { + let result = panic::catch_unwind(|| { + println!("hello!"); + }); + assert!(result.is_ok()); + + let result = panic::catch_unwind(|| { + panic!("oh no!"); + }); + assert!(result.is_err()); +} ``` * This can be useful in servers which should keep running even if a single