Repository: vitiral/path_abs (language: rust)

Issue:
Making Stdio from {FileRead, FileWrite}
I don't see an easy way to use FileRead and FileWrite in `std::process::Command::{stdout, stderr, stdin}` as there's no way to get the File and they don't impl `Into<Stdio>`


Discussion / hints:
definitely need to implement `Into<File>` for all the `File*` types, that was an oversight.

Fix patch:
diff --git a/Cargo.toml b/Cargo.toml
index 652821b..2b84562 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,7 +13,7 @@ license = "MIT OR Apache-2.0"
 name = "path_abs"
 readme = "README.md"
 repository = "https://github.com/vitiral/path_abs"
-version = "0.4.0"
+version = "0.4.1"
 
 [dependencies]
 std_prelude = "0.2.12"
diff --git a/src/edit.rs b/src/edit.rs
index 2e00d5d..9640dc8 100644
--- a/src/edit.rs
+++ b/src/edit.rs
@@ -229,3 +229,9 @@ impl Deref for FileEdit {
         &self.0
     }
 }
+
+impl Into<File> for FileEdit {
+    fn into(self) -> File {
+        self.0.into()
+    }
+}
diff --git a/src/read.rs b/src/read.rs
index 51f1d46..9943dfd 100644
--- a/src/read.rs
+++ b/src/read.rs
@@ -106,3 +106,9 @@ impl Deref for FileRead {
         &self.0
     }
 }
+
+impl Into<File> for FileRead {
+    fn into(self) -> File {
+        self.0.into()
+    }
+}
diff --git a/src/ser.rs b/src/ser.rs
index a09e222..874231b 100644
--- a/src/ser.rs
+++ b/src/ser.rs
@@ -7,6 +7,8 @@
  */
 use serde::{self, Deserialize, Deserializer, Serialize, Serializer};
 use stfu8;
+use std::string::ToString;
+use std::str::FromStr;
 
 #[cfg(unix)]
 use std::ffi::OsStr;
@@ -27,16 +29,6 @@ macro_rules! map_err {
 }
 
 impl PathArc {
-    /// Convert the `PathArc` into an STFU8 `String`.
-    pub fn to_string(&self) -> String {
-        self.to_stfu8()
-    }
-
-    /// Convert STFU8 `str` to a `PathArc`.
-    pub fn from_str(s: &str) -> Result<PathArc, stfu8::DecodeError> {
-        PathArc::from_stfu8(s)
-    }
-
     #[cfg(unix)]
     pub(crate) fn to_stfu8(&self) -> String {
         let bytes = self.as_os_str().as_bytes();
@@ -64,6 +56,22 @@ impl PathArc {
     }
 }
 
+impl ToString for PathArc {
+    /// Convert the `PathArc` into an STFU8 `String`.
+    fn to_string(&self) -> String {
+        self.to_stfu8()
+    }
+}
+
+impl FromStr for PathArc {
+    type Err = stfu8::DecodeError;
+
+    /// Convert STFU8 `str` to a `PathArc`.
+    fn from_str(s: &str) -> Result<PathArc, stfu8::DecodeError> {
+        PathArc::from_stfu8(s)
+    }
+}
+
 impl Serialize for PathArc {
     fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
     where
diff --git a/src/write.rs b/src/write.rs
index 0ef5e92..2391865 100644
--- a/src/write.rs
+++ b/src/write.rs
@@ -203,3 +203,9 @@ impl Deref for FileWrite {
         &self.0
     }
 }
+
+impl Into<File> for FileWrite {
+    fn into(self) -> File {
+        self.0.into()
+    }
+}


Test patch:
diff --git a/tests/test_absolute.rs b/tests/test_absolute.rs
index 1df95da..6013e0b 100644
--- a/tests/test_absolute.rs
+++ b/tests/test_absolute.rs
@@ -11,9 +11,9 @@
 //! - `..` paths that consume the "root"
 
 extern crate path_abs;
-extern crate tempdir;
 #[macro_use]
 extern crate pretty_assertions;
+extern crate tempdir;
 
 use path_abs::*;
 use std::path::Path;
@@ -23,7 +23,11 @@ use std::env;
 fn test_absolute() {
     if cfg!(windows) {
         let result = Path::new(r"\").canonicalize();
-        assert!(result.is_ok(), "Should work before set_current_dir is called: {:?}", result);
+        assert!(
+            result.is_ok(),
+            "Should work before set_current_dir is called: {:?}",
+            result
+        );
     }
     let tmp = tempdir::TempDir::new("ex").unwrap();
     let tmp = tmp.path();
diff --git a/tests/test_windows.rs b/tests/test_windows.rs
index a95d169..0cfb5fd 100644
--- a/tests/test_windows.rs
+++ b/tests/test_windows.rs
@@ -8,9 +8,9 @@
 //! Test assumptions about windows
 #![cfg_attr(not(windows), allow(dead_code))]
 extern crate path_abs;
-extern crate tempdir;
 #[macro_use]
 extern crate pretty_assertions;
+extern crate tempdir;
 
 use std::path::Path;
 use std::process::Command;