From 97fde8cc1b05ec3b37317ed8b80ef395f70ff321 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 4 Aug 2016 14:09:06 +0200 Subject: [PATCH] Replace unwrap() with map() --- libimagerror/src/trace.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libimagerror/src/trace.rs b/libimagerror/src/trace.rs index 35b1f1f8..3cb4e78b 100644 --- a/libimagerror/src/trace.rs +++ b/libimagerror/src/trace.rs @@ -62,10 +62,12 @@ pub fn trace_error_dbg(e: &Error) { /// processed. fn print_trace_maxdepth(idx: u64, e: &Error, max: u64) -> Option<&Error> { if e.cause().is_some() && idx > 0 { - match print_trace_maxdepth(idx - 1, e.cause().unwrap(), max) { - None => write!(stderr(), "\n").ok(), - Some(_) => write!(stderr(), " -- caused:\n").ok(), - }; + e.cause().map(|cause| { + match print_trace_maxdepth(idx - 1, cause, max) { + None => write!(stderr(), "\n").ok(), + Some(_) => write!(stderr(), " -- caused:\n").ok(), + }; + }); } else { write!(stderr(), "\n").ok(); }