Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #[macro_use]
- extern crate serde_json; // 1.0.38
- use std::panic::catch_unwind;
- fn main() {
- let c = || serde_json::from_value::<i32>(json!({
- "a": 1
- }));
- let out = if let Ok(e) = catch_unwind(c) {
- println!("didn't panic");
- e
- } else {
- println!("paniced");
- c()
- };
- println!("{:?}", out);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement