about summary refs log tree commit diff
path: root/src/libcollections
diff options
context:
space:
mode:
authorNick Cameron <ncameron@mozilla.com>2014-09-25 22:41:49 +1200
committerNick Cameron <ncameron@mozilla.com>2014-10-02 13:19:45 +1300
commitdf2f1fa7680a86ba228f004e7de731e91a1df1fe (patch)
tree8176be0292df7395c72f72588f69b06925a8c7a0 /src/libcollections
parent40b9f5ded50ac4ce8c9323921ec556ad611af6b7 (diff)
downloadrust-df2f1fa7680a86ba228f004e7de731e91a1df1fe.tar.gz
rust-df2f1fa7680a86ba228f004e7de731e91a1df1fe.zip
Remove the `_` suffix from slice methods.
Deprecates slicing methods from ImmutableSlice/MutableSlice in favour of slicing syntax or the methods in Slice/SliceMut.

Closes #17273.
Diffstat (limited to 'src/libcollections')
-rw-r--r--src/libcollections/trie.rs18
-rw-r--r--src/libcollections/vec.rs53
2 files changed, 71 insertions, 0 deletions
diff --git a/src/libcollections/trie.rs b/src/libcollections/trie.rs
index 04175173feb..9bfc8e08d8d 100644
--- a/src/libcollections/trie.rs
+++ b/src/libcollections/trie.rs
@@ -389,6 +389,7 @@ macro_rules! bound {
 
 impl<T> TrieMap<T> {
     // If `upper` is true then returns upper_bound else returns lower_bound.
+    #[cfg(stage0)]
     #[inline]
     fn bound<'a>(&'a self, key: uint, upper: bool) -> Entries<'a, T> {
         bound!(Entries, self = self,
@@ -396,6 +397,14 @@ impl<T> TrieMap<T> {
                slice_from = slice_from_, iter = iter,
                mutability = )
     }
+    #[cfg(not(stage0))]
+    #[inline]
+    fn bound<'a>(&'a self, key: uint, upper: bool) -> Entries<'a, T> {
+        bound!(Entries, self = self,
+               key = key, is_upper = upper,
+               slice_from = slice_from, iter = iter,
+               mutability = )
+    }
 
     /// Gets an iterator pointing to the first key-value pair whose key is not less than `key`.
     /// If all keys in the map are less than `key` an empty iterator is returned.
@@ -431,6 +440,7 @@ impl<T> TrieMap<T> {
         self.bound(key, true)
     }
     // If `upper` is true then returns upper_bound else returns lower_bound.
+    #[cfg(stage0)]
     #[inline]
     fn bound_mut<'a>(&'a mut self, key: uint, upper: bool) -> MutEntries<'a, T> {
         bound!(MutEntries, self = self,
@@ -438,6 +448,14 @@ impl<T> TrieMap<T> {
                slice_from = slice_from_mut_, iter = iter_mut,
                mutability = mut)
     }
+    #[cfg(not(stage0))]
+    #[inline]
+    fn bound_mut<'a>(&'a mut self, key: uint, upper: bool) -> MutEntries<'a, T> {
+        bound!(MutEntries, self = self,
+               key = key, is_upper = upper,
+               slice_from = slice_from_mut, iter = iter_mut,
+               mutability = mut)
+    }
 
     /// Deprecated: use `lower_bound_mut`.
     #[deprecated = "use lower_bound_mut"]
diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs
index 01d0bc460b9..ee6f5e840be 100644
--- a/src/libcollections/vec.rs
+++ b/src/libcollections/vec.rs
@@ -23,6 +23,7 @@ use core::num;
 use core::ops;
 use core::ptr;
 use core::raw::Slice as RawSlice;
+use core::slice::Slice as SliceSlice;
 use core::uint;
 
 use {Mutable, MutableSeq};
@@ -459,6 +460,36 @@ impl<T> Index<uint,T> for Vec<T> {
     }
 }*/
 
+// Annoying helper function because there are two Slice::as_slice functions in
+// scope.
+#[inline]
+fn slice_to_slice<'a, T, U: Slice<T>>(this: &'a U) -> &'a [T] {
+    this.as_slice()
+}
+
+
+#[cfg(not(stage0))]
+impl<T> ops::Slice<uint, [T]> for Vec<T> {
+    #[inline]
+    fn as_slice<'a>(&'a self) -> &'a [T] {
+        slice_to_slice(self)
+    }
+
+    #[inline]
+    fn slice_from<'a>(&'a self, start: &uint) -> &'a [T] {
+        slice_to_slice(self).slice_from(start)
+    }
+
+    #[inline]
+    fn slice_to<'a>(&'a self, end: &uint) -> &'a [T] {
+        slice_to_slice(self).slice_to(end)
+    }
+    #[inline]
+    fn slice<'a>(&'a self, start: &uint, end: &uint) -> &'a [T] {
+        slice_to_slice(self).slice(start, end)
+    }
+}
+#[cfg(stage0)]
 impl<T> ops::Slice<uint, [T]> for Vec<T> {
     #[inline]
     fn as_slice_<'a>(&'a self) -> &'a [T] {
@@ -480,6 +511,28 @@ impl<T> ops::Slice<uint, [T]> for Vec<T> {
     }
 }
 
+#[cfg(not(stage0))]
+impl<T> ops::SliceMut<uint, [T]> for Vec<T> {
+    #[inline]
+    fn as_mut_slice<'a>(&'a mut self) -> &'a mut [T] {
+        self.as_mut_slice()
+    }
+
+    #[inline]
+    fn slice_from_mut<'a>(&'a mut self, start: &uint) -> &'a mut [T] {
+        self.as_mut_slice().slice_from_mut(start)
+    }
+
+    #[inline]
+    fn slice_to_mut<'a>(&'a mut self, end: &uint) -> &'a mut [T] {
+        self.as_mut_slice().slice_to_mut(end)
+    }
+    #[inline]
+    fn slice_mut<'a>(&'a mut self, start: &uint, end: &uint) -> &'a mut [T] {
+        self.as_mut_slice().slice_mut(start, end)
+    }
+}
+#[cfg(stage0)]
 impl<T> ops::SliceMut<uint, [T]> for Vec<T> {
     #[inline]
     fn as_mut_slice_<'a>(&'a mut self) -> &'a mut [T] {