diff options
| author | bors <bors@rust-lang.org> | 2014-10-07 06:17:11 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-10-07 06:17:11 +0000 |
| commit | e62ef37cfae680e60584731635a89e955121a5bb (patch) | |
| tree | 768fd0552e75e5380b1122ac56448f0465df8fb3 /src/libstd/path | |
| parent | 8d702167ba6af50c64683685bae4956cb094a23a (diff) | |
| parent | eb2fdc8b065218476744ed428097c859616c62f0 (diff) | |
| download | rust-e62ef37cfae680e60584731635a89e955121a5bb.tar.gz rust-e62ef37cfae680e60584731635a89e955121a5bb.zip | |
auto merge of #17807 : nick29581/rust/slice6, r=aturon
r? @aturon
Diffstat (limited to 'src/libstd/path')
| -rw-r--r-- | src/libstd/path/mod.rs | 10 | ||||
| -rw-r--r-- | src/libstd/path/posix.rs | 24 | ||||
| -rw-r--r-- | src/libstd/path/windows.rs | 2 |
3 files changed, 18 insertions, 18 deletions
diff --git a/src/libstd/path/mod.rs b/src/libstd/path/mod.rs index 16552daae36..6a122990246 100644 --- a/src/libstd/path/mod.rs +++ b/src/libstd/path/mod.rs @@ -76,7 +76,7 @@ use option::{Option, None, Some}; use str; use str::{MaybeOwned, Str, StrSlice}; use string::String; -use slice::{Slice, CloneableVector}; +use slice::{AsSlice, CloneableVector}; use slice::{ImmutablePartialEqSlice, ImmutableSlice}; use vec::Vec; @@ -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.slice_to(pos) + Some(pos) => name[..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.slice_from(pos+1)) + Some(pos) => Some(name[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.slice_to(idx).to_vec()), + (Some(idx), 0) => Some(name[..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.slice_to(idx)); + v.push_all(name[..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 805db000686..196ac7507ea 100644 --- a/src/libstd/path/posix.rs +++ b/src/libstd/path/posix.rs @@ -21,7 +21,7 @@ use iter::{DoubleEndedIterator, AdditiveIterator, Extendable, Iterator, Map}; use option::{Option, None, Some}; use str::Str; use str; -use slice::{CloneableVector, Splits, Slice, VectorVector, +use slice::{CloneableVector, Splits, AsSlice, VectorVector, ImmutablePartialEqSlice, ImmutableSlice}; use vec::Vec; @@ -165,7 +165,7 @@ impl GenericPathUnsafe for Path { None => { self.repr = Path::normalize(filename); } - Some(idx) if self.repr.slice_from(idx+1) == b".." => { + Some(idx) if self.repr[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.slice_to(idx+1)); + v.push_all(self.repr[..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.slice_to(1), - Some(idx) if self.repr.slice_from(idx+1) == b".." => self.repr.as_slice(), - Some(idx) => self.repr.slice_to(idx) + Some(0) => self.repr[..1], + Some(idx) if self.repr[idx+1..] == b".." => self.repr.as_slice(), + Some(idx) => self.repr[..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.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)) + 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..]) } } @@ -367,11 +367,11 @@ impl Path { /// Returns a normalized byte vector representation of a path, by removing all empty /// components, and unnecessary . and .. components. - fn normalize<V: Slice<u8>+CloneableVector<u8>>(v: V) -> Vec<u8> { + fn normalize<V: AsSlice<u8>+CloneableVector<u8>>(v: V) -> Vec<u8> { // 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().slice_from(1) } else { v.as_slice() }; + let v_ = if is_abs { v.as_slice()[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.slice_from(1) + self.repr[1..] } else { self.repr.as_slice() }; let mut ret = v.split(is_sep_byte); if v.is_empty() { diff --git a/src/libstd/path/windows.rs b/src/libstd/path/windows.rs index 803db4848ad..ec3f87bc45a 100644 --- a/src/libstd/path/windows.rs +++ b/src/libstd/path/windows.rs @@ -23,7 +23,7 @@ use io::Writer; use iter::{AdditiveIterator, DoubleEndedIterator, Extendable, Iterator, Map}; use mem; use option::{Option, Some, None}; -use slice::{Slice, ImmutableSlice}; +use slice::{AsSlice, ImmutableSlice}; use str::{CharSplits, Str, StrAllocating, StrVector, StrSlice}; use string::String; use unicode::char::UnicodeChar; |
