Repository: o0Ignition0o/cargo-scout (language: rust)

Issue:
Linter: Use Into<PathBuf> instead of Pathbuf ?
The problem with Into<PathBuf> is that it's not sized, so making this change would probably require me to dig into Associated types( We would need to create an `Impl Linter<P> where P: Into<PathBuf> + Sized`, so I'm a bit scared to do it right now :/

OTOH it would allow us to allow more inputs (such as &str for example) so it would be really cool 

_Originally posted by @o0Ignition0o in https://github.com/o0Ignition0o/cargo-scout/pull/74/review_comment/create_


Discussion / hints:

Fix patch:
diff --git a/cargo-scout-lib/src/linter/clippy.rs b/cargo-scout-lib/src/linter/clippy.rs
index cca4b58..c1004f7 100644
--- a/cargo-scout-lib/src/linter/clippy.rs
+++ b/cargo-scout-lib/src/linter/clippy.rs
@@ -51,7 +51,11 @@ struct Span {
 }
 
 impl linter::Linter for Clippy {
-    fn lints(&self, working_dir: PathBuf) -> Result<Vec<linter::Lint>, crate::error::Error> {
+    fn lints(
+        &self,
+        working_dir: impl Into<PathBuf>,
+    ) -> Result<Vec<linter::Lint>, crate::error::Error> {
+        let working_dir = working_dir.into();
         println!(
             "[Clippy] - getting lints for directory {}",
             &working_dir.to_str().unwrap_or("<no directory>")
diff --git a/cargo-scout-lib/src/linter/mod.rs b/cargo-scout-lib/src/linter/mod.rs
index adf59c9..1b9e592 100644
--- a/cargo-scout-lib/src/linter/mod.rs
+++ b/cargo-scout-lib/src/linter/mod.rs
@@ -4,7 +4,7 @@ pub mod clippy;
 pub mod rustfmt;
 
 pub trait Linter {
-    fn lints(&self, working_dir: PathBuf) -> Result<Vec<Lint>, crate::error::Error>;
+    fn lints(&self, working_dir: impl Into<PathBuf>) -> Result<Vec<Lint>, crate::error::Error>;
 }
 
 /// This struct contains the lint,
diff --git a/cargo-scout-lib/src/linter/rustfmt.rs b/cargo-scout-lib/src/linter/rustfmt.rs
index e88268c..e89c6b3 100644
--- a/cargo-scout-lib/src/linter/rustfmt.rs
+++ b/cargo-scout-lib/src/linter/rustfmt.rs
@@ -10,7 +10,8 @@ use std::process::Command;
 pub struct RustFmt {}
 
 impl Linter for RustFmt {
-    fn lints(&self, working_dir: PathBuf) -> Result<Vec<Lint>, Error> {
+    fn lints(&self, working_dir: impl Into<PathBuf>) -> Result<Vec<Lint>, Error> {
+        let working_dir = working_dir.into();
         println!(
             "[RustFmt] - checking format for directory {}",
             &working_dir.to_str().unwrap_or("<no directory>")
diff --git a/cargo-scout-lib/src/scout/mod.rs b/cargo-scout-lib/src/scout/mod.rs
index 927ed80..695b1f2 100644
--- a/cargo-scout-lib/src/scout/mod.rs
+++ b/cargo-scout-lib/src/scout/mod.rs
@@ -136,7 +136,10 @@ mod scout_tests {
         }
     }
     impl Linter for TestLinter {
-        fn lints(&self, _working_dir: PathBuf) -> Result<Vec<Lint>, crate::error::Error> {
+        fn lints(
+            &self,
+            _working_dir: impl Into<PathBuf>,
+        ) -> Result<Vec<Lint>, crate::error::Error> {
             *self.lints_times_called.borrow_mut() += 1;
             Ok(self.lints.clone())
         }


Test patch: