mirror of
https://github.com/haraldh/chainerror.git
synced 2025-01-31 00:56:41 +01:00
516 B
516 B
Downcast the Errors
std::error::Error
comes with some helper methods to get to the original object of the
&(dyn Error + 'static)
returned by .source()
.
pub fn downcast_ref<T: Error + 'static>(&self) -> Option<&T>
pub fn downcast_mut<T: Error + 'static>(&mut self) -> Option<&mut T>
This is how it looks like, when using those:
use crate::chainerror::*;
{{#include ../examples/tutorial6.rs:2:}}
# #[allow(dead_code)]
# mod chainerror {
{{#includecomment ../src/lib.rs}}
# }