about summary refs log tree commit diff
path: root/src/libcore/str/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/libcore/str/mod.rs')
-rw-r--r--src/libcore/str/mod.rs20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs
index a28e5614417..c4e97fe3b7f 100644
--- a/src/libcore/str/mod.rs
+++ b/src/libcore/str/mod.rs
@@ -26,7 +26,7 @@ use iter::{Map, Iterator, IteratorExt, DoubleEndedIterator};
 use kinds::Sized;
 use mem;
 use num::Int;
-use ops::{Fn, FnMut};
+use ops::{Fn, FnMut, Index};
 use option::Option::{self, None, Some};
 use ptr::PtrExt;
 use raw::{Repr, Slice};
@@ -581,7 +581,7 @@ impl NaiveSearcher {
 
     fn next(&mut self, haystack: &[u8], needle: &[u8]) -> Option<(uint, uint)> {
         while self.position + needle.len() <= haystack.len() {
-            if haystack[self.position .. self.position + needle.len()] == needle {
+            if haystack.index(&(self.position .. self.position + needle.len())) == needle {
                 let match_pos = self.position;
                 self.position += needle.len(); // add 1 for all matches
                 return Some((match_pos, match_pos + needle.len()));
@@ -702,10 +702,10 @@ impl TwoWaySearcher {
         //
         // What's going on is we have some critical factorization (u, v) of the
         // needle, and we want to determine whether u is a suffix of
-        // v[..period]. If it is, we use "Algorithm CP1". Otherwise we use
+        // v.index(&(0..period)). If it is, we use "Algorithm CP1". Otherwise we use
         // "Algorithm CP2", which is optimized for when the period of the needle
         // is large.
-        if needle[..crit_pos] == needle[period.. period + crit_pos] {
+        if needle.index(&(0..crit_pos)) == needle.index(&(period.. period + crit_pos)) {
             TwoWaySearcher {
                 crit_pos: crit_pos,
                 period: period,
@@ -1121,28 +1121,28 @@ mod traits {
 
     impl ops::Index<ops::Range<uint>, str> for str {
         #[inline]
-        fn index(&self, &index: &ops::Range<uint>) -> &str {
+        fn index(&self, index: &ops::Range<uint>) -> &str {
             self.slice(index.start, index.end)
         }
     }
 
     impl ops::Index<ops::RangeTo<uint>, str> for str {
         #[inline]
-        fn index(&self, &index: &ops::RangeTo<uint>) -> &str {
+        fn index(&self, index: &ops::RangeTo<uint>) -> &str {
             self.slice_to(index.end)
         }
     }
 
     impl ops::Index<ops::RangeFrom<uint>, str> for str {
         #[inline]
-        fn index(&self, &index: &ops::RangeFrom<uint>) -> &str {
+        fn index(&self, index: &ops::RangeFrom<uint>) -> &str {
             self.slice_from(index.start)
         }
     }
 
     impl ops::Index<ops::FullRange, str> for str {
         #[inline]
-        fn index(&self, &index: &ops::FullRange) -> &str {
+        fn index(&self, _index: &ops::FullRange) -> &str {
             self
         }
     }
@@ -1412,13 +1412,13 @@ impl StrExt for str {
     #[inline]
     fn starts_with(&self, needle: &str) -> bool {
         let n = needle.len();
-        self.len() >= n && needle.as_bytes() == self.as_bytes()[..n]
+        self.len() >= n && needle.as_bytes() == self.as_bytes().index(&(0..n))
     }
 
     #[inline]
     fn ends_with(&self, needle: &str) -> bool {
         let (m, n) = (self.len(), needle.len());
-        m >= n && needle.as_bytes() == self.as_bytes()[m-n..]
+        m >= n && needle.as_bytes() == self.as_bytes().index(&((m-n)..))
     }
 
     #[inline]