From 9ea1811e2103dbe3d55d74cda2349db7c3bfee31 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 4 Aug 2016 14:09:22 +0200 Subject: [PATCH] Replace unwrap() with map() --- libimagerror/src/trace.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libimagerror/src/trace.rs b/libimagerror/src/trace.rs index 3cb4e78b..58a0b945 100644 --- a/libimagerror/src/trace.rs +++ b/libimagerror/src/trace.rs @@ -77,7 +77,7 @@ fn print_trace_maxdepth(idx: u64, e: &Error, max: u64) -> Option<&Error> { /// Count errors in `Error::cause()` recursively fn count_error_causes(e: &Error) -> u64 { - 1 + if e.cause().is_some() { count_error_causes(e.cause().unwrap()) } else { 0 } + 1 + e.cause().map(|c| count_error_causes(c)).unwrap_or(0) } fn print_trace_dbg(idx: u64, e: &Error) {