about summary refs log tree commit diff
path: root/src/libstd/path
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-10-02 23:42:31 +0000
committerbors <bors@rust-lang.org>2014-10-02 23:42:31 +0000
commitd0af3feebb57bc58c52de69ab51f92dc7082500b (patch)
treed39de6be5866c0f0f37f9f3219b8217c873d8b52 /src/libstd/path
parentb2d4eb186e99b66051be9089f836c66a558dd995 (diff)
parentd2ea0315e09cbd495a67c9e3d5053b57e2b5a8b7 (diff)
downloadrust-d0af3feebb57bc58c52de69ab51f92dc7082500b.tar.gz
rust-d0af3feebb57bc58c52de69ab51f92dc7082500b.zip
auto merge of #17715 : aturon/rust/revert-slice-ops-libs, r=alexcrichton
This PR reverts https://github.com/rust-lang/rust/pull/17620, which caused a significant regression for slices.

As discussed with @alexcrichton, all of the public-facing changes of the earlier PR need to be rolled back, and it's not clear that we should move the libraries over to this new notation yet anyway (especially given its feature-gated status).

Closes #17710
Diffstat (limited to 'src/libstd/path')
-rw-r--r--src/libstd/path/mod.rs8
-rw-r--r--src/libstd/path/posix.rs20
2 files changed, 14 insertions, 14 deletions
diff --git a/src/libstd/path/mod.rs b/src/libstd/path/mod.rs
index 63c81695aff..16552daae36 100644
--- a/src/libstd/path/mod.rs
+++ b/src/libstd/path/mod.rs
@@ -357,7 +357,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
                 match name.rposition_elem(&dot) {
                     None | Some(0) => name,
                     Some(1) if name == b".." => name,
-                    Some(pos) => name[..pos]
+                    Some(pos) => name.slice_to(pos)
                 }
             })
         }
@@ -404,7 +404,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
                 match name.rposition_elem(&dot) {
                     None | Some(0) => None,
                     Some(1) if name == b".." => None,
-                    Some(pos) => Some(name[pos+1..])
+                    Some(pos) => Some(name.slice_from(pos+1))
                 }
             }
         }
@@ -480,7 +480,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
             let extlen = extension.container_as_bytes().len();
             match (name.rposition_elem(&dot), extlen) {
                 (None, 0) | (Some(0), 0) => None,
-                (Some(idx), 0) => Some(name[..idx].to_vec()),
+                (Some(idx), 0) => Some(name.slice_to(idx).to_vec()),
                 (idx, extlen) => {
                     let idx = match idx {
                         None | Some(0) => name.len(),
@@ -489,7 +489,7 @@ pub trait GenericPath: Clone + GenericPathUnsafe {
 
                     let mut v;
                     v = Vec::with_capacity(idx + extlen + 1);
-                    v.push_all(name[..idx]);
+                    v.push_all(name.slice_to(idx));
                     v.push(dot);
                     v.push_all(extension.container_as_bytes());
                     Some(v)
diff --git a/src/libstd/path/posix.rs b/src/libstd/path/posix.rs
index 3043c25f761..9c4139853c5 100644
--- a/src/libstd/path/posix.rs
+++ b/src/libstd/path/posix.rs
@@ -165,7 +165,7 @@ impl GenericPathUnsafe for Path {
             None => {
                 self.repr = Path::normalize(filename);
             }
-            Some(idx) if self.repr[idx+1..] == b".." => {
+            Some(idx) if self.repr.slice_from(idx+1) == b".." => {
                 let mut v = Vec::with_capacity(self.repr.len() + 1 + filename.len());
                 v.push_all(self.repr.as_slice());
                 v.push(SEP_BYTE);
@@ -175,7 +175,7 @@ impl GenericPathUnsafe for Path {
             }
             Some(idx) => {
                 let mut v = Vec::with_capacity(idx + 1 + filename.len());
-                v.push_all(self.repr[..idx+1]);
+                v.push_all(self.repr.slice_to(idx+1));
                 v.push_all(filename);
                 // FIXME: this is slow
                 self.repr = Path::normalize(v.as_slice());
@@ -216,9 +216,9 @@ impl GenericPath for Path {
         match self.sepidx {
             None if b".." == self.repr.as_slice() => self.repr.as_slice(),
             None => dot_static,
-            Some(0) => self.repr[..1],
-            Some(idx) if self.repr[idx+1..] == b".." => self.repr.as_slice(),
-            Some(idx) => self.repr[..idx]
+            Some(0) => self.repr.slice_to(1),
+            Some(idx) if self.repr.slice_from(idx+1) == b".." => self.repr.as_slice(),
+            Some(idx) => self.repr.slice_to(idx)
         }
     }
 
@@ -227,9 +227,9 @@ impl GenericPath for Path {
             None if b"." == self.repr.as_slice() ||
                 b".." == self.repr.as_slice() => None,
             None => Some(self.repr.as_slice()),
-            Some(idx) if self.repr[idx+1..] == b".." => None,
-            Some(0) if self.repr[1..].is_empty() => None,
-            Some(idx) => Some(self.repr[idx+1..])
+            Some(idx) if self.repr.slice_from(idx+1) == b".." => None,
+            Some(0) if self.repr.slice_from(1).is_empty() => None,
+            Some(idx) => Some(self.repr.slice_from(idx+1))
         }
     }
 
@@ -371,7 +371,7 @@ impl Path {
         // borrowck is being very picky
         let val = {
             let is_abs = !v.as_slice().is_empty() && v.as_slice()[0] == SEP_BYTE;
-            let v_ = if is_abs { v.as_slice()[1..] } else { v.as_slice() };
+            let v_ = if is_abs { v.as_slice().slice_from(1) } else { v.as_slice() };
             let comps = normalize_helper(v_, is_abs);
             match comps {
                 None => None,
@@ -410,7 +410,7 @@ impl Path {
     /// A path of "/" yields no components. A path of "." yields one component.
     pub fn components<'a>(&'a self) -> Components<'a> {
         let v = if self.repr[0] == SEP_BYTE {
-            self.repr[1..]
+            self.repr.slice_from(1)
         } else { self.repr.as_slice() };
         let mut ret = v.split(is_sep_byte);
         if v.is_empty() {