From 23887358dd31d9570bb1d595ac45f99f95b8dbd5 Mon Sep 17 00:00:00 2001 From: Jakob Stoklund Olesen Date: Sat, 17 Sep 2016 12:36:35 -0700 Subject: [PATCH] Simplify with unwrap_or_else(). --- cranelift/src/tools/filetest/concurrent.rs | 23 ++++++++++------------ 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/cranelift/src/tools/filetest/concurrent.rs b/cranelift/src/tools/filetest/concurrent.rs index 3123124086..30abb844d4 100644 --- a/cranelift/src/tools/filetest/concurrent.rs +++ b/cranelift/src/tools/filetest/concurrent.rs @@ -127,20 +127,17 @@ fn worker_thread(thread_num: usize, }) .unwrap(); - let result = match catch_unwind(|| runone::run(path.as_path())) { - Ok(r) => r, - Err(e) => { - // The test panicked, leaving us a `Box`. - // Panics are usually strings. - if let Some(msg) = e.downcast_ref::() { - Err(format!("panicked in worker #{}: {}", thread_num, msg)) - } else if let Some(msg) = e.downcast_ref::<&'static str>() { - Err(format!("panicked in worker #{}: {}", thread_num, msg)) - } else { - Err(format!("panicked in worker #{}", thread_num)) - } + let result = catch_unwind(|| runone::run(path.as_path())).unwrap_or_else(|e| { + // The test panicked, leaving us a `Box`. + // Panics are usually strings. + if let Some(msg) = e.downcast_ref::() { + Err(format!("panicked in worker #{}: {}", thread_num, msg)) + } else if let Some(msg) = e.downcast_ref::<&'static str>() { + Err(format!("panicked in worker #{}: {}", thread_num, msg)) + } else { + Err(format!("panicked in worker #{}", thread_num)) } - }; + }); replies.send(Reply::Done { jobid: jobid,