Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/windirstat/walkdir.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Gallant <jamslam@gmail.com>2020-01-11 20:27:20 +0300
committerAndrew Gallant <jamslam@gmail.com>2020-01-11 20:28:57 +0300
commit64367023b1a8675f8b97997dcdae194692acc504 (patch)
treea8637472cc8672f582bb74d27ebc4cd348973596 /src/error.rs
parent580acab20f9b9c4e5441b461859c00a99c1deee2 (diff)
style: use 'dyn' for trait objects
And also add a `source` method on the `Error` impl. And finally, permit the use of the deprecated `description` method, since removing it would be a breaking change.
Diffstat (limited to 'src/error.rs')
-rw-r--r--src/error.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/error.rs b/src/error.rs
index ab9b17a..b084a58 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -203,6 +203,7 @@ impl Error {
}
impl error::Error for Error {
+ #[allow(deprecated)]
fn description(&self) -> &str {
match self.inner {
ErrorInner::Io { ref err, .. } => err.description(),
@@ -210,7 +211,11 @@ impl error::Error for Error {
}
}
- fn cause(&self) -> Option<&error::Error> {
+ fn cause(&self) -> Option<&dyn error::Error> {
+ self.source()
+ }
+
+ fn source(&self) -> Option<&(dyn error::Error + 'static)> {
match self.inner {
ErrorInner::Io { ref err, .. } => Some(err),
ErrorInner::Loop { .. } => None,