about summary refs log tree commit diff
path: root/src/libextra/fileinput.rs
diff options
context:
space:
mode:
authorKevin Ballard <kevin@sb.org>2013-10-05 19:49:32 -0700
committerKevin Ballard <kevin@sb.org>2013-10-15 22:18:30 -0700
commitd6d9b926836b1f1c2b8b3fe4ab35dc63bec7ffcd (patch)
treee197783b86700e71d94c9bc6d0254eb25b16cc0c /src/libextra/fileinput.rs
parented539e14712539473c3e89604cb69e2307110772 (diff)
downloadrust-d6d9b926836b1f1c2b8b3fe4ab35dc63bec7ffcd.tar.gz
rust-d6d9b926836b1f1c2b8b3fe4ab35dc63bec7ffcd.zip
path2: Adjust the API to remove all the _str mutation methods
Add a new trait BytesContainer that is implemented for both byte vectors
and strings.

Convert Path::from_vec and ::from_str to one function, Path::new().

Remove all the _str-suffixed mutation methods (push, join, with_*,
set_*) and modify the non-suffixed versions to use BytesContainer.
Diffstat (limited to 'src/libextra/fileinput.rs')
-rw-r--r--src/libextra/fileinput.rs16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/libextra/fileinput.rs b/src/libextra/fileinput.rs
index 08d1222ff46..8f176d5ccea 100644
--- a/src/libextra/fileinput.rs
+++ b/src/libextra/fileinput.rs
@@ -358,11 +358,11 @@ instance. `stdin_hyphen` controls whether `-` represents `stdin` or
 a literal `-`.
 */
 pub fn make_path_option_vec(vec: &[~str], stdin_hyphen : bool) -> ~[Option<Path>] {
-    vec.iter().map(|str| {
-        if stdin_hyphen && "-" == *str {
+    vec.iter().map(|s| {
+        if stdin_hyphen && "-" == *s {
             None
         } else {
-            Some(Path::from_str(*str))
+            Some(Path::new(s.as_slice()))
         }
     }).collect()
 }
@@ -435,14 +435,14 @@ mod test {
     fn test_make_path_option_vec() {
         let strs = [~"some/path",
                     ~"some/other/path"];
-        let paths = ~[Some(Path::from_str("some/path")),
-                      Some(Path::from_str("some/other/path"))];
+        let paths = ~[Some(Path::new("some/path")),
+                      Some(Path::new("some/other/path"))];
 
         assert_eq!(make_path_option_vec(strs, true), paths.clone());
         assert_eq!(make_path_option_vec(strs, false), paths);
 
         assert_eq!(make_path_option_vec([~"-"], true), ~[None]);
-        assert_eq!(make_path_option_vec([~"-"], false), ~[Some(Path::from_str("-"))]);
+        assert_eq!(make_path_option_vec([~"-"], false), ~[Some(Path::new("-"))]);
     }
 
     #[test]
@@ -567,9 +567,9 @@ mod test {
     #[test]
     fn test_no_trailing_newline() {
         let f1 =
-            Some(Path::from_str("tmp/lib-fileinput-test-no-trailing-newline-1.tmp"));
+            Some(Path::new("tmp/lib-fileinput-test-no-trailing-newline-1.tmp"));
         let f2 =
-            Some(Path::from_str("tmp/lib-fileinput-test-no-trailing-newline-2.tmp"));
+            Some(Path::new("tmp/lib-fileinput-test-no-trailing-newline-2.tmp"));
 
         {
             let mut wr = file::open(f1.get_ref(), io::CreateOrTruncate,