diff options
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/ffi/os_str.rs | 20 | ||||
| -rw-r--r-- | src/libstd/path.rs | 40 | ||||
| -rw-r--r-- | src/libstd/sys/unix/os_str.rs | 4 | ||||
| -rw-r--r-- | src/libstd/sys/windows/os_str.rs | 4 |
4 files changed, 9 insertions, 59 deletions
diff --git a/src/libstd/ffi/os_str.rs b/src/libstd/ffi/os_str.rs index 5851c6e2998..24844ad0961 100644 --- a/src/libstd/ffi/os_str.rs +++ b/src/libstd/ffi/os_str.rs @@ -113,23 +113,9 @@ impl From<String> for OsString { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a> From<&'a String> for OsString { - fn from(s: &'a String) -> OsString { - OsString { inner: Buf::from_str(s) } - } -} - -#[stable(feature = "rust1", since = "1.0.0")] -impl<'a> From<&'a str> for OsString { - fn from(s: &'a str) -> OsString { - OsString { inner: Buf::from_str(s) } - } -} - -#[stable(feature = "rust1", since = "1.0.0")] -impl<'a> From<&'a OsStr> for OsString { - fn from(s: &'a OsStr) -> OsString { - OsString { inner: s.inner.to_owned() } +impl<'a, T: ?Sized + AsRef<OsStr>> From<&'a T> for OsString { + fn from(s: &'a T) -> OsString { + s.as_ref().to_os_string() } } diff --git a/src/libstd/path.rs b/src/libstd/path.rs index 50f79967f55..58d3ae9f7cf 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -1038,23 +1038,16 @@ impl PathBuf { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a> From<&'a Path> for PathBuf { - fn from(s: &'a Path) -> PathBuf { - s.to_path_buf() +impl<'a, T: ?Sized + AsRef<OsStr>> From<&'a T> for PathBuf { + fn from(s: &'a T) -> PathBuf { + PathBuf::from(s.as_ref().to_os_string()) } } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a> From<&'a str> for PathBuf { - fn from(s: &'a str) -> PathBuf { - PathBuf::from(OsString::from(s)) - } -} - -#[stable(feature = "rust1", since = "1.0.0")] -impl<'a> From<&'a String> for PathBuf { - fn from(s: &'a String) -> PathBuf { - PathBuf::from(OsString::from(s)) +impl From<OsString> for PathBuf { + fn from(s: OsString) -> PathBuf { + PathBuf { inner: s } } } @@ -1066,27 +1059,6 @@ impl From<String> for PathBuf { } #[stable(feature = "rust1", since = "1.0.0")] -impl<'a> From<&'a OsStr> for PathBuf { - fn from(s: &'a OsStr) -> PathBuf { - PathBuf::from(OsString::from(s)) - } -} - -#[stable(feature = "rust1", since = "1.0.0")] -impl<'a> From<&'a OsString> for PathBuf { - fn from(s: &'a OsString) -> PathBuf { - PathBuf::from(s.to_os_string()) - } -} - -#[stable(feature = "rust1", since = "1.0.0")] -impl From<OsString> for PathBuf { - fn from(s: OsString) -> PathBuf { - PathBuf { inner: s } - } -} - -#[stable(feature = "rust1", since = "1.0.0")] impl<P: AsRef<Path>> iter::FromIterator<P> for PathBuf { fn from_iter<I: IntoIterator<Item = P>>(iter: I) -> PathBuf { let mut buf = PathBuf::new(); diff --git a/src/libstd/sys/unix/os_str.rs b/src/libstd/sys/unix/os_str.rs index 3b8d18d87a0..69d876a48a4 100644 --- a/src/libstd/sys/unix/os_str.rs +++ b/src/libstd/sys/unix/os_str.rs @@ -46,10 +46,6 @@ impl Buf { Buf { inner: s.into_bytes() } } - pub fn from_str(s: &str) -> Buf { - Buf { inner: s.as_bytes().to_vec() } - } - pub fn as_slice(&self) -> &Slice { unsafe { mem::transmute(&*self.inner) } } diff --git a/src/libstd/sys/windows/os_str.rs b/src/libstd/sys/windows/os_str.rs index ad1e6c4b0e7..91905ae7489 100644 --- a/src/libstd/sys/windows/os_str.rs +++ b/src/libstd/sys/windows/os_str.rs @@ -45,10 +45,6 @@ impl Buf { Buf { inner: Wtf8Buf::from_string(s) } } - pub fn from_str(s: &str) -> Buf { - Buf { inner: Wtf8Buf::from_str(s) } - } - pub fn as_slice(&self) -> &Slice { unsafe { mem::transmute(self.inner.as_slice()) } } |
