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
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.
-rw-r--r--src/error.rs7
-rw-r--r--src/lib.rs3
-rw-r--r--src/tests/util.rs4
3 files changed, 9 insertions, 5 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,
diff --git a/src/lib.rs b/src/lib.rs
index 51778e4..6a7bd63 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -105,7 +105,6 @@ for entry in walker.filter_entry(|e| !is_hidden(e)) {
#![deny(missing_docs)]
#![allow(unknown_lints)]
-#![allow(bare_trait_objects)]
#[cfg(test)]
#[macro_use]
@@ -251,7 +250,7 @@ struct WalkDirOptions {
min_depth: usize,
max_depth: usize,
sorter: Option<Box<
- FnMut(&DirEntry,&DirEntry) -> Ordering + Send + Sync + 'static
+ dyn FnMut(&DirEntry,&DirEntry) -> Ordering + Send + Sync + 'static
>>,
contents_first: bool,
same_file_system: bool,
diff --git a/src/tests/util.rs b/src/tests/util.rs
index d31a28d..ab977cd 100644
--- a/src/tests/util.rs
+++ b/src/tests/util.rs
@@ -11,12 +11,12 @@ use {DirEntry, Error};
#[macro_export]
macro_rules! err {
($($tt:tt)*) => {
- Box::<error::Error + Send + Sync>::from(format!($($tt)*))
+ Box::<dyn error::Error + Send + Sync>::from(format!($($tt)*))
}
}
/// A convenient result type alias.
-pub type Result<T> = result::Result<T, Box<error::Error + Send + Sync>>;
+pub type Result<T> = result::Result<T, Box<dyn error::Error + Send + Sync>>;
/// The result of running a recursive directory iterator on a single directory.
#[derive(Debug)]