From 9956c6442528166b45cab4f38f7b695f0b35a573 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Fri, 18 Oct 2019 13:02:15 -0600 Subject: [PATCH] style: Update to 2018 edition --- Cargo.toml | 1 + src/assert.rs | 20 ++++++++++---------- src/fixture/errors.rs | 10 +++++----- src/lib.rs | 26 ++++++++++---------------- tests/assert.rs | 3 +-- 5 files changed, 27 insertions(+), 33 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d98c8d8..7b4da9b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,6 +10,7 @@ documentation = "http://docs.rs/assert_fs/" readme = "README.md" categories = ["development-tools::testing"] keywords = ["filesystem", "test", "assert", "fixture"] +edition = "2018" [dependencies] tempfile = "3.0" diff --git a/src/assert.rs b/src/assert.rs index 939f6f0..9c744e1 100644 --- a/src/assert.rs +++ b/src/assert.rs @@ -34,7 +34,7 @@ use predicates::str::PredicateStrExt; use predicates_core; use predicates_tree::CaseTreeExt; -use fixture; +use crate::fixture; /// Assert the state of files within [`TempDir`]. /// @@ -240,12 +240,12 @@ impl BytesContentPathPredicate { impl predicates_core::reflection::PredicateReflection for BytesContentPathPredicate { fn parameters<'a>( &'a self, - ) -> Box> + 'a> { + ) -> Box> + 'a> { self.0.parameters() } /// Nested `Predicate`s of the current `Predicate`. - fn children<'a>(&'a self) -> Box> + 'a> { + fn children<'a>(&'a self) -> Box> + 'a> { self.0.children() } } @@ -265,7 +265,7 @@ impl predicates_core::Predicate for BytesContentPathPredicate { } impl fmt::Display for BytesContentPathPredicate { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.0.fmt(f) } } @@ -316,12 +316,12 @@ impl StrContentPathPredicate { impl predicates_core::reflection::PredicateReflection for StrContentPathPredicate { fn parameters<'a>( &'a self, - ) -> Box> + 'a> { + ) -> Box> + 'a> { self.0.parameters() } /// Nested `Predicate`s of the current `Predicate`. - fn children<'a>(&'a self) -> Box> + 'a> { + fn children<'a>(&'a self) -> Box> + 'a> { self.0.children() } } @@ -341,7 +341,7 @@ impl predicates_core::Predicate for StrContentPathPredicate { } impl fmt::Display for StrContentPathPredicate { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.0.fmt(f) } } @@ -400,12 +400,12 @@ where { fn parameters<'a>( &'a self, - ) -> Box> + 'a> { + ) -> Box> + 'a> { self.0.parameters() } /// Nested `Predicate`s of the current `Predicate`. - fn children<'a>(&'a self) -> Box> + 'a> { + fn children<'a>(&'a self) -> Box> + 'a> { self.0.children() } } @@ -431,7 +431,7 @@ impl

fmt::Display for StrPathPredicate

where P: predicates_core::Predicate, { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.0.fmt(f) } } diff --git a/src/fixture/errors.rs b/src/fixture/errors.rs index 3f98f97..9fa81f8 100644 --- a/src/fixture/errors.rs +++ b/src/fixture/errors.rs @@ -58,7 +58,7 @@ pub enum FixtureKind { } impl fmt::Display for FixtureKind { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { FixtureKind::Walk => write!(f, "Failed when walking the source tree,"), FixtureKind::CopyFile => write!(f, "Failed when copying a file."), @@ -74,7 +74,7 @@ impl fmt::Display for FixtureKind { #[derive(Debug)] pub struct FixtureError { kind: FixtureKind, - cause: Option>, + cause: Option>, } impl FixtureError { @@ -94,16 +94,16 @@ impl Error for FixtureError { "Failed to initialize fixture" } - fn cause(&self) -> Option<&Error> { + fn cause(&self) -> Option<&dyn Error> { self.cause.as_ref().map(|c| { - let c: &Error = c.as_ref(); + let c: &dyn Error = c.as_ref(); c }) } } impl fmt::Display for FixtureError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self.cause { Some(ref cause) => write!( f, diff --git a/src/lib.rs b/src/lib.rs index ca64e6b..203dd7b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -64,33 +64,27 @@ #![warn(missing_docs)] -extern crate globwalk; -extern crate predicates; -extern crate predicates_core; -extern crate predicates_tree; -extern crate tempfile; - pub mod assert; pub mod fixture; // Pulling this in for convenience-sake #[doc(inline)] -pub use fixture::TempDir; +pub use crate::fixture::TempDir; // Pulling this in for convenience-sake #[doc(inline)] -pub use fixture::NamedTempFile; +pub use crate::fixture::NamedTempFile; /// Extension traits that are useful to have available. pub mod prelude { - pub use assert::PathAssert; - pub use fixture::FileTouch; - pub use fixture::FileWriteBin; - pub use fixture::FileWriteFile; - pub use fixture::FileWriteStr; - pub use fixture::PathChild; - pub use fixture::PathCopy; - pub use fixture::PathCreateDir; + pub use crate::assert::PathAssert; + pub use crate::fixture::FileTouch; + pub use crate::fixture::FileWriteBin; + pub use crate::fixture::FileWriteFile; + pub use crate::fixture::FileWriteStr; + pub use crate::fixture::PathChild; + pub use crate::fixture::PathCopy; + pub use crate::fixture::PathCreateDir; } #[macro_use] diff --git a/tests/assert.rs b/tests/assert.rs index de05acb..dfa121c 100644 --- a/tests/assert.rs +++ b/tests/assert.rs @@ -1,5 +1,4 @@ -extern crate assert_fs; -extern crate predicates; +use assert_fs; use assert_fs::prelude::*; use predicates::prelude::*;