Replace unwrap() with map()

This commit is contained in:
Matthias Beyer 2016-08-04 14:09:22 +02:00
parent 97fde8cc1b
commit 9ea1811e21

View file

@ -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) {