about summary refs log tree commit diff
path: root/src/libstd/path
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2014-05-16 10:45:16 -0700
committerPatrick Walton <pcwalton@mimiga.net>2014-05-22 14:42:01 -0700
commit36195eb91f15975fed7555a3aa52807ecd5698a1 (patch)
treed0e99310be4a24e76b8d6b13f05ec79c1f89b6ba /src/libstd/path
parente402e75f4eb79af09b9451f0f232f994b3e2c998 (diff)
downloadrust-36195eb91f15975fed7555a3aa52807ecd5698a1.tar.gz
rust-36195eb91f15975fed7555a3aa52807ecd5698a1.zip
libstd: Remove `~str` from all `libstd` modules except `fmt` and `str`.
Diffstat (limited to 'src/libstd/path')
-rw-r--r--src/libstd/path/mod.rs16
-rw-r--r--src/libstd/path/posix.rs4
-rw-r--r--src/libstd/path/windows.rs24
3 files changed, 19 insertions, 25 deletions
diff --git a/src/libstd/path/mod.rs b/src/libstd/path/mod.rs
index 2960d55f337..1bd099e5d24 100644
--- a/src/libstd/path/mod.rs
+++ b/src/libstd/path/mod.rs
@@ -519,28 +519,12 @@ impl<'a> BytesContainer for &'a str {
     fn is_str(_: Option<&'a str>) -> bool { true }
 }
 
-impl BytesContainer for ~str {
-    #[inline]
-    fn container_as_bytes<'a>(&'a self) -> &'a [u8] {
-        self.as_bytes()
-    }
-    #[inline]
-    fn container_as_str<'a>(&'a self) -> Option<&'a str> {
-        Some(self.as_slice())
-    }
-    #[inline]
-    fn is_str(_: Option<~str>) -> bool { true }
-}
 impl BytesContainer for StrBuf {
     #[inline]
     fn container_as_bytes<'a>(&'a self) -> &'a [u8] {
         self.as_bytes()
     }
     #[inline]
-    fn container_into_owned_bytes(self) -> Vec<u8> {
-        self.into_bytes()
-    }
-    #[inline]
     fn container_as_str<'a>(&'a self) -> Option<&'a str> {
         Some(self.as_slice())
     }
diff --git a/src/libstd/path/posix.rs b/src/libstd/path/posix.rs
index 4f7132dc6e4..8a939a92846 100644
--- a/src/libstd/path/posix.rs
+++ b/src/libstd/path/posix.rs
@@ -781,7 +781,7 @@ mod tests {
         t!(s: "a/b/c", ["d", "e"], "a/b/c/d/e");
         t!(s: "a/b/c", ["d", "/e"], "/e");
         t!(s: "a/b/c", ["d", "/e", "f"], "/e/f");
-        t!(s: "a/b/c", ["d".to_owned(), "e".to_owned()], "a/b/c/d/e");
+        t!(s: "a/b/c", ["d".to_strbuf(), "e".to_strbuf()], "a/b/c/d/e");
         t!(v: b!("a/b/c"), [b!("d"), b!("e")], b!("a/b/c/d/e"));
         t!(v: b!("a/b/c"), [b!("d"), b!("/e"), b!("f")], b!("/e/f"));
         t!(v: b!("a/b/c"), [Vec::from_slice(b!("d")), Vec::from_slice(b!("e"))], b!("a/b/c/d/e"));
@@ -886,7 +886,7 @@ mod tests {
         t!(s: "a/b/c", ["d", "e"], "a/b/c/d/e");
         t!(s: "a/b/c", ["..", "d"], "a/b/d");
         t!(s: "a/b/c", ["d", "/e", "f"], "/e/f");
-        t!(s: "a/b/c", ["d".to_owned(), "e".to_owned()], "a/b/c/d/e");
+        t!(s: "a/b/c", ["d".to_strbuf(), "e".to_strbuf()], "a/b/c/d/e");
         t!(v: b!("a/b/c"), [b!("d"), b!("e")], b!("a/b/c/d/e"));
         t!(v: b!("a/b/c"), [Vec::from_slice(b!("d")), Vec::from_slice(b!("e"))], b!("a/b/c/d/e"));
     }
diff --git a/src/libstd/path/windows.rs b/src/libstd/path/windows.rs
index 176788edcc4..1c671b30e80 100644
--- a/src/libstd/path/windows.rs
+++ b/src/libstd/path/windows.rs
@@ -136,10 +136,17 @@ impl<'a> ToCStr for &'a Path {
 }
 
 impl<S: Writer> ::hash::Hash<S> for Path {
+    #[cfg(not(test))]
     #[inline]
     fn hash(&self, state: &mut S) {
         self.repr.hash(state)
     }
+
+    #[cfg(test)]
+    #[inline]
+    fn hash(&self, _: &mut S) {
+        // No-op because the `hash` implementation will be wrong.
+    }
 }
 
 impl BytesContainer for Path {
@@ -589,7 +596,7 @@ impl GenericPath for Path {
                     }
                 }
             }
-            Some(Path::new(comps.connect("\\")))
+            Some(Path::new(comps.connect("\\").into_strbuf()))
         }
     }
 
@@ -754,7 +761,10 @@ impl Path {
                                 let mut s = StrBuf::from_str(s.slice_to(len));
                                 unsafe {
                                     let v = s.as_mut_vec();
-                                    *v.get_mut(0) = v.get(0).to_ascii().to_upper().to_byte();
+                                    *v.get_mut(0) = v.get(0)
+                                                     .to_ascii()
+                                                     .to_upper()
+                                                     .to_byte();
                                 }
                                 if is_abs {
                                     // normalize C:/ to C:\
@@ -913,7 +923,7 @@ pub fn make_non_verbatim(path: &Path) -> Option<Path> {
         }
         Some(VerbatimUNCPrefix(_,_)) => {
             // \\?\UNC\server\share
-            Path::new(format!(r"\\{}", repr.slice_from(7)))
+            Path::new(format_strbuf!(r"\\{}", repr.slice_from(7)))
         }
     };
     if new_path.prefix.is_none() {
@@ -1331,9 +1341,9 @@ mod tests {
     #[test]
     fn test_display_str() {
         let path = Path::new("foo");
-        assert_eq!(path.display().to_str(), "foo".to_owned());
+        assert_eq!(path.display().to_str(), "foo".to_strbuf());
         let path = Path::new(b!("\\"));
-        assert_eq!(path.filename_display().to_str(), "".to_owned());
+        assert_eq!(path.filename_display().to_str(), "".to_strbuf());
 
         let path = Path::new("foo");
         let mo = path.display().as_maybe_owned();
@@ -1594,7 +1604,7 @@ mod tests {
         t!(s: "a\\b\\c", ["d", "e"], "a\\b\\c\\d\\e");
         t!(s: "a\\b\\c", ["d", "\\e"], "\\e");
         t!(s: "a\\b\\c", ["d", "\\e", "f"], "\\e\\f");
-        t!(s: "a\\b\\c", ["d".to_owned(), "e".to_owned()], "a\\b\\c\\d\\e");
+        t!(s: "a\\b\\c", ["d".to_strbuf(), "e".to_strbuf()], "a\\b\\c\\d\\e");
         t!(v: b!("a\\b\\c"), [b!("d"), b!("e")], b!("a\\b\\c\\d\\e"));
         t!(v: b!("a\\b\\c"), [b!("d"), b!("\\e"), b!("f")], b!("\\e\\f"));
         t!(v: b!("a\\b\\c"), [Vec::from_slice(b!("d")), Vec::from_slice(b!("e"))],
@@ -1735,7 +1745,7 @@ mod tests {
         t!(s: "a\\b\\c", ["d", "e"], "a\\b\\c\\d\\e");
         t!(s: "a\\b\\c", ["..", "d"], "a\\b\\d");
         t!(s: "a\\b\\c", ["d", "\\e", "f"], "\\e\\f");
-        t!(s: "a\\b\\c", ["d".to_owned(), "e".to_owned()], "a\\b\\c\\d\\e");
+        t!(s: "a\\b\\c", ["d".to_strbuf(), "e".to_strbuf()], "a\\b\\c\\d\\e");
         t!(v: b!("a\\b\\c"), [b!("d"), b!("e")], b!("a\\b\\c\\d\\e"));
         t!(v: b!("a\\b\\c"), [Vec::from_slice(b!("d")), Vec::from_slice(b!("e"))],
            b!("a\\b\\c\\d\\e"));