diff options
Diffstat (limited to 'src/libstd/path/mod.rs')
| -rw-r--r-- | src/libstd/path/mod.rs | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/libstd/path/mod.rs b/src/libstd/path/mod.rs index b020164158c..021aae5a601 100644 --- a/src/libstd/path/mod.rs +++ b/src/libstd/path/mod.rs @@ -68,6 +68,7 @@ use fmt; use iter::IteratorExt; use option::Option; use option::Option::{None, Some}; +use prelude::{FullRange, Index}; use str; use str::StrExt; use string::{String, CowString}; @@ -351,7 +352,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.index(&(0..pos)) } }) } @@ -398,7 +399,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.index(&((pos+1)..))) } } } @@ -474,7 +475,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.index(&(0..idx)).to_vec()), (idx, extlen) => { let idx = match idx { None | Some(0) => name.len(), @@ -483,7 +484,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.index(&(0..idx))); v.push(dot); v.push_all(extension.container_as_bytes()); Some(v) @@ -869,7 +870,7 @@ impl BytesContainer for String { } #[inline] fn container_as_str(&self) -> Option<&str> { - Some(self[]) + Some(self.index(&FullRange)) } #[inline] fn is_str(_: Option<&String>) -> bool { true } @@ -885,7 +886,7 @@ impl BytesContainer for [u8] { impl BytesContainer for Vec<u8> { #[inline] fn container_as_bytes(&self) -> &[u8] { - self[] + self.index(&FullRange) } } |
