about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2014-09-29 08:14:16 -0700
committerAlex Crichton <alex@alexcrichton.com>2014-09-29 08:14:16 -0700
commit735d16b1b0221736f5d8cd9e754d759b59c5ca11 (patch)
tree963b6df8e63c36d6a9aeec66908d491e0a680340 /src/libcore
parente44393a953a4654aa14d37df588cf490e1120240 (diff)
parentaa2814fd4e9266ac96b5c95cb44ec7f7ad86703b (diff)
downloadrust-735d16b1b0221736f5d8cd9e754d759b59c5ca11.tar.gz
rust-735d16b1b0221736f5d8cd9e754d759b59c5ca11.zip
rollup merge of #17585 : sfackler/string-slice
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/str.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/libcore/str.rs b/src/libcore/str.rs
index 7e399902a4b..343b8e0b64b 100644
--- a/src/libcore/str.rs
+++ b/src/libcore/str.rs
@@ -1123,6 +1123,7 @@ pub mod traits {
     use collections::Collection;
     use iter::Iterator;
     use option::{Option, Some};
+    use ops;
     use str::{Str, StrSlice, eq_slice};
 
     impl<'a> Ord for &'a str {
@@ -1162,6 +1163,28 @@ pub mod traits {
         #[inline]
         fn equiv(&self, other: &S) -> bool { eq_slice(*self, other.as_slice()) }
     }
+
+    impl ops::Slice<uint, str> for str {
+        #[inline]
+        fn as_slice_<'a>(&'a self) -> &'a str {
+            self
+        }
+
+        #[inline]
+        fn slice_from_<'a>(&'a self, from: &uint) -> &'a str {
+            self.slice_from(*from)
+        }
+
+        #[inline]
+        fn slice_to_<'a>(&'a self, to: &uint) -> &'a str {
+            self.slice_to(*to)
+        }
+
+        #[inline]
+        fn slice_<'a>(&'a self, from: &uint, to: &uint) -> &'a str {
+            self.slice(*from, *to)
+        }
+    }
 }
 
 /// Any string that can be represented as a slice