diff options
| author | Aaron Turon <aturon@mozilla.com> | 2015-01-17 16:15:52 -0800 |
|---|---|---|
| committer | Aaron Turon <aturon@mozilla.com> | 2015-01-21 08:11:07 -0800 |
| commit | a506d4cbfe8f20a2725c7efd9d43359a0bbd0e9e (patch) | |
| tree | d3cc252236786a58efbdd2b3c4bf3f12af88039e /src/libcollections | |
| parent | 092ba6a8563b5c95f5aa53a705eaba6cc94e2da7 (diff) | |
| download | rust-a506d4cbfe8f20a2725c7efd9d43359a0bbd0e9e.tar.gz rust-a506d4cbfe8f20a2725c7efd9d43359a0bbd0e9e.zip | |
Fallout from stabilization.
Diffstat (limited to 'src/libcollections')
| -rw-r--r-- | src/libcollections/btree/node.rs | 21 | ||||
| -rw-r--r-- | src/libcollections/ring_buf.rs | 2 | ||||
| -rw-r--r-- | src/libcollections/slice.rs | 2 | ||||
| -rw-r--r-- | src/libcollections/str.rs | 26 |
4 files changed, 28 insertions, 23 deletions
diff --git a/src/libcollections/btree/node.rs b/src/libcollections/btree/node.rs index fa890643089..50857c78469 100644 --- a/src/libcollections/btree/node.rs +++ b/src/libcollections/btree/node.rs @@ -21,7 +21,7 @@ use core::prelude::*; use core::borrow::BorrowFrom; use core::cmp::Ordering::{Greater, Less, Equal}; use core::iter::Zip; -use core::ops::{Deref, DerefMut}; +use core::ops::{Deref, DerefMut, Index, IndexMut}; use core::ptr::Unique; use core::{slice, mem, ptr, cmp, num, raw}; use alloc::heap; @@ -1487,7 +1487,7 @@ impl<K, V, E, Impl> AbsTraversal<Impl> macro_rules! node_slice_impl { ($NodeSlice:ident, $Traversal:ident, - $as_slices_internal:ident, $slice_from:ident, $slice_to:ident, $iter:ident) => { + $as_slices_internal:ident, $index:ident, $iter:ident) => { impl<'a, K: Ord + 'a, V: 'a> $NodeSlice<'a, K, V> { /// Performs linear search in a slice. Returns a tuple of (index, is_exact_match). fn search_linear<Q: ?Sized>(&self, key: &Q) -> (uint, bool) @@ -1521,10 +1521,10 @@ macro_rules! node_slice_impl { edges: if !self.has_edges { self.edges } else { - self.edges.$slice_from(pos) + self.edges.$index(&(pos ..)) }, - keys: self.keys.slice_from(pos), - vals: self.vals.$slice_from(pos), + keys: &self.keys[pos ..], + vals: self.vals.$index(&(pos ..)), head_is_edge: !pos_is_kv, tail_is_edge: self.tail_is_edge, } @@ -1550,10 +1550,10 @@ macro_rules! node_slice_impl { edges: if !self.has_edges { self.edges } else { - self.edges.$slice_to(pos + 1) + self.edges.$index(&(.. (pos + 1))) }, - keys: self.keys.slice_to(pos), - vals: self.vals.$slice_to(pos), + keys: &self.keys[..pos], + vals: self.vals.$index(&(.. pos)), head_is_edge: self.head_is_edge, tail_is_edge: !pos_is_kv, } @@ -1583,6 +1583,5 @@ macro_rules! node_slice_impl { } } -node_slice_impl!(NodeSlice, Traversal, as_slices_internal, slice_from, slice_to, iter); -node_slice_impl!(MutNodeSlice, MutTraversal, as_slices_internal_mut, slice_from_mut, - slice_to_mut, iter_mut); +node_slice_impl!(NodeSlice, Traversal, as_slices_internal, index, iter); +node_slice_impl!(MutNodeSlice, MutTraversal, as_slices_internal_mut, index_mut, iter_mut); diff --git a/src/libcollections/ring_buf.rs b/src/libcollections/ring_buf.rs index b9cb4be7c18..69d64bcdf6d 100644 --- a/src/libcollections/ring_buf.rs +++ b/src/libcollections/ring_buf.rs @@ -578,7 +578,7 @@ impl<T> RingBuf<T> { if contiguous { let (empty, buf) = buf.split_at_mut(0); - (buf.slice_mut(tail, head), empty) + (&mut buf[tail .. head], empty) } else { let (mid, right) = buf.split_at_mut(tail); let (left, _) = mid.split_at_mut(head); diff --git a/src/libcollections/slice.rs b/src/libcollections/slice.rs index a640e4ee0e3..16e5a89f343 100644 --- a/src/libcollections/slice.rs +++ b/src/libcollections/slice.rs @@ -686,7 +686,7 @@ impl<T> SliceExt for [T] { #[inline] fn move_from(&mut self, mut src: Vec<T>, start: uint, end: uint) -> uint { - for (a, b) in self.iter_mut().zip(src.slice_mut(start, end).iter_mut()) { + for (a, b) in self.iter_mut().zip(src[start .. end].iter_mut()) { mem::swap(a, b); } cmp::min(self.len(), end-start) diff --git a/src/libcollections/str.rs b/src/libcollections/str.rs index 94554fd1e81..6608d0ee9a7 100644 --- a/src/libcollections/str.rs +++ b/src/libcollections/str.rs @@ -752,21 +752,15 @@ pub trait StrExt: Index<FullRange, Output = str> { /// Deprecated: use `s[a .. b]` instead. #[deprecated = "use slice notation [a..b] instead"] - fn slice(&self, begin: uint, end: uint) -> &str { - core_str::StrExt::slice(&self[], begin, end) - } + fn slice(&self, begin: uint, end: uint) -> &str; /// Deprecated: use `s[a..]` instead. #[deprecated = "use slice notation [a..] instead"] - fn slice_from(&self, begin: uint) -> &str { - core_str::StrExt::slice_from(&self[], begin) - } + fn slice_from(&self, begin: uint) -> &str; /// Deprecated: use `s[..a]` instead. #[deprecated = "use slice notation [..a] instead"] - fn slice_to(&self, end: uint) -> &str { - core_str::StrExt::slice_to(&self[], end) - } + fn slice_to(&self, end: uint) -> &str; /// Returns a slice of the string from the character range /// [`begin`..`end`). @@ -1304,7 +1298,19 @@ pub trait StrExt: Index<FullRange, Output = str> { } #[stable] -impl StrExt for str {} +impl StrExt for str { + fn slice(&self, begin: uint, end: uint) -> &str { + &self[begin..end] + } + + fn slice_from(&self, begin: uint) -> &str { + &self[begin..] + } + + fn slice_to(&self, end: uint) -> &str { + &self[..end] + } +} #[cfg(test)] mod tests { |
