about summary refs log tree commit diff
path: root/src/libstd/path
diff options
context:
space:
mode:
authorKevin Ballard <kevin@sb.org>2013-10-15 23:32:14 -0700
committerKevin Ballard <kevin@sb.org>2013-10-16 11:18:06 -0700
commit6eade9e9143e496167d66298e8bbac5d9dfa3e19 (patch)
treed5cf6690f8ac9f7dfecb73774a1b5f7b5149c196 /src/libstd/path
parent40b324f0dec364a9fa71f9f8b47b8ab156f6d61e (diff)
downloadrust-6eade9e9143e496167d66298e8bbac5d9dfa3e19.tar.gz
rust-6eade9e9143e496167d66298e8bbac5d9dfa3e19.zip
path2: Update for latest master
Also fix some issues that crept into earlier commits during the conflict
resoution for the rebase.
Diffstat (limited to 'src/libstd/path')
-rw-r--r--src/libstd/path/posix.rs4
-rw-r--r--src/libstd/path/windows.rs27
2 files changed, 20 insertions, 11 deletions
diff --git a/src/libstd/path/posix.rs b/src/libstd/path/posix.rs
index 5eea65a5b91..271937dfcf2 100644
--- a/src/libstd/path/posix.rs
+++ b/src/libstd/path/posix.rs
@@ -791,7 +791,7 @@ mod tests {
             (s: $path:expr, $op:ident, $exp:expr, opt) => (
                 {
                     let path = Path::new($path);
-                    let left = path.$op().map(|&x| str::from_utf8_slice(x));
+                    let left = path.$op().map(|x| str::from_utf8_slice(x));
                     assert_eq!(left, $exp);
                 }
             );
@@ -1313,7 +1313,7 @@ mod tests {
                     let path = Path::new($path);
                     let other = Path::new($other);
                     let res = path.path_relative_from(&other);
-                    assert_eq!(res.and_then_ref(|x| x.as_str()), $exp);
+                    assert_eq!(res.as_ref().and_then(|x| x.as_str()), $exp);
                 }
             )
         )
diff --git a/src/libstd/path/windows.rs b/src/libstd/path/windows.rs
index 9576e62f439..0ee0d9c79d1 100644
--- a/src/libstd/path/windows.rs
+++ b/src/libstd/path/windows.rs
@@ -258,7 +258,7 @@ impl GenericPathUnsafe for Path {
             // if me is verbatim, we need to pre-normalize the new path
             let path_ = if is_verbatim(me) { Path::normalize__(path, None) }
                         else { None };
-            let pathlen = path_.map_default(path.len(), |p| p.len());
+            let pathlen = path_.as_ref().map_default(path.len(), |p| p.len());
             let mut s = str::with_capacity(me.repr.len() + 1 + pathlen);
             s.push_str(me.repr);
             let plen = me.prefix_len();
@@ -368,7 +368,7 @@ impl GenericPath for Path {
 
     #[inline]
     fn filename<'a>(&'a self) -> Option<&'a [u8]> {
-        self.filename_str().map_move(|x| x.as_bytes())
+        self.filename_str().map(|x| x.as_bytes())
     }
 
     /// See `GenericPath::filename_str` for info.
@@ -388,13 +388,13 @@ impl GenericPath for Path {
     #[inline]
     fn filestem_str<'a>(&'a self) -> Option<&'a str> {
         // filestem() returns a byte vector that's guaranteed valid UTF-8
-        self.filestem().map_move(cast::transmute)
+        self.filestem().map(cast::transmute)
     }
 
     #[inline]
     fn extension_str<'a>(&'a self) -> Option<&'a str> {
         // extension() returns a byte vector that's guaranteed valid UTF-8
-        self.extension().map_move(cast::transmute)
+        self.extension().map(cast::transmute)
     }
 
     fn dir_path(&self) -> Path {
@@ -728,16 +728,25 @@ impl Path {
                             DiskPrefix => {
                                 let len = prefix_len(prefix) + is_abs as uint;
                                 let mut s = s.slice_to(len).to_owned();
-                                s[0] = s[0].to_ascii().to_upper().to_byte();
+                                unsafe {
+                                    str::raw::as_owned_vec(&mut s)[0] =
+                                        s[0].to_ascii().to_upper().to_byte();
+                                }
                                 if is_abs {
-                                    s[2] = sep as u8; // normalize C:/ to C:\
+                                    // normalize C:/ to C:\
+                                    unsafe {
+                                        str::raw::as_owned_vec(&mut s)[2] = sep as u8;
+                                    }
                                 }
                                 Some(s)
                             }
                             VerbatimDiskPrefix => {
                                 let len = prefix_len(prefix) + is_abs as uint;
                                 let mut s = s.slice_to(len).to_owned();
-                                s[4] = s[4].to_ascii().to_upper().to_byte();
+                                unsafe {
+                                    str::raw::as_owned_vec(&mut s)[4] =
+                                        s[4].to_ascii().to_upper().to_byte();
+                                }
                                 Some(s)
                             }
                             _ => {
@@ -2204,10 +2213,10 @@ mod tests {
                     let other = Path::new($other);
                     let res = path.path_relative_from(&other);
                     let exp = $exp;
-                    assert!(res.and_then_ref(|x| x.as_str()) == exp,
+                    assert!(res.as_ref().and_then(|x| x.as_str()) == exp,
                             "`{}`.path_relative_from(`{}`): Expected {:?}, got {:?}",
                             path.as_str().unwrap(), other.as_str().unwrap(), exp,
-                            res.and_then_ref(|x| x.as_str()));
+                            res.as_ref().and_then(|x| x.as_str()));
                 }
             )
         )