rust/tests/run-pass/catch.rs

8 lines
169 B
Rust
Raw Normal View History

2017-05-26 17:27:39 -07:00
use std::panic::{catch_unwind, AssertUnwindSafe};
fn main() {
let mut i = 3;
2018-11-26 15:31:53 +01:00
let _val = catch_unwind(AssertUnwindSafe(|| {i -= 2;} ));
println!("{}", i);
2017-05-26 17:27:39 -07:00
}