Replace unwrap() with map()

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

View file

@ -62,10 +62,12 @@ pub fn trace_error_dbg(e: &Error) {
/// processed. /// processed.
fn print_trace_maxdepth(idx: u64, e: &Error, max: u64) -> Option<&Error> { fn print_trace_maxdepth(idx: u64, e: &Error, max: u64) -> Option<&Error> {
if e.cause().is_some() && idx > 0 { if e.cause().is_some() && idx > 0 {
match print_trace_maxdepth(idx - 1, e.cause().unwrap(), max) { e.cause().map(|cause| {
None => write!(stderr(), "\n").ok(), match print_trace_maxdepth(idx - 1, cause, max) {
Some(_) => write!(stderr(), " -- caused:\n").ok(), None => write!(stderr(), "\n").ok(),
}; Some(_) => write!(stderr(), " -- caused:\n").ok(),
};
});
} else { } else {
write!(stderr(), "\n").ok(); write!(stderr(), "\n").ok();
} }