about summary refs log tree commit diff
path: root/src/libcollections/string.rs
diff options
context:
space:
mode:
authorNick Cameron <ncameron@mozilla.com>2014-09-30 15:34:27 +1300
committerNick Cameron <ncameron@mozilla.com>2014-10-02 14:50:22 +1300
commit6e0611a48707a1f5d90aee32a02b2b15957ef25b (patch)
tree343d4bb719d8472b78b33e35ea34cd959ab4e742 /src/libcollections/string.rs
parent95cfc35607ccf5f02f02de56a35a9ef50fa23a82 (diff)
downloadrust-6e0611a48707a1f5d90aee32a02b2b15957ef25b.tar.gz
rust-6e0611a48707a1f5d90aee32a02b2b15957ef25b.zip
Review and rebasing changes
Diffstat (limited to 'src/libcollections/string.rs')
-rw-r--r--src/libcollections/string.rs29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/libcollections/string.rs b/src/libcollections/string.rs
index 206e392f664..1032a504330 100644
--- a/src/libcollections/string.rs
+++ b/src/libcollections/string.rs
@@ -927,6 +927,7 @@ impl<S: Str> Add<S, String> for String {
     }
 }
 
+#[cfg(stage0)]
 impl ops::Slice<uint, str> for String {
     #[inline]
     fn as_slice_<'a>(&'a self) -> &'a str {
@@ -949,6 +950,34 @@ impl ops::Slice<uint, str> for String {
     }
 }
 
+#[cfg(not(stage0))]
+#[inline]
+fn str_to_slice<'a, U: Str>(this: &'a U) -> &'a str {
+    this.as_slice()
+}
+#[cfg(not(stage0))]
+impl ops::Slice<uint, str> for String {
+    #[inline]
+    fn as_slice<'a>(&'a self) -> &'a str {
+        str_to_slice(self)
+    }
+
+    #[inline]
+    fn slice_from<'a>(&'a self, from: &uint) -> &'a str {
+        self[][*from..]
+    }
+
+    #[inline]
+    fn slice_to<'a>(&'a self, to: &uint) -> &'a str {
+        self[][..*to]
+    }
+
+    #[inline]
+    fn slice<'a>(&'a self, from: &uint, to: &uint) -> &'a str {
+        self[][*from..*to]
+    }
+}
+
 /// Unsafe operations
 #[unstable = "waiting on raw module conventions"]
 pub mod raw {