From e7525cf6200e5b62a4b1a2f3131f68d946fb331e Mon Sep 17 00:00:00 2001 From: Aaron Turon Date: Thu, 26 Mar 2015 13:39:23 -0700 Subject: Revise use of conversion traits This commit revises `path` and `os_str` to use blanket impls for `From` on reference types. This both cuts down on the number of required impls, and means that you can pass through e.g. `T: AsRef` to `PathBuf::from` without an intermediate call to `as_ref`. It also makes a FIXME note for later generalizing the blanket impls for `AsRef` and `AsMut` to use `Deref`/`DerefMut`, once it is possible to do so. --- src/libstd/sys/unix/os_str.rs | 4 ---- src/libstd/sys/windows/os_str.rs | 4 ---- 2 files changed, 8 deletions(-) (limited to 'src/libstd/sys') 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()) } } -- cgit 1.4.1-3-g733a5