#[inline]
fn split_at(&self, mid: uint) -> (&[T], &[T]) {
- (self.index(&(0..mid)), self.index(&(mid..)))
+ (&self[..mid], &self[mid..])
}
#[inline]
}
#[inline]
- fn tail(&self) -> &[T] { self.index(&(1..)) }
+ fn tail(&self) -> &[T] { &self[1..] }
#[inline]
fn init(&self) -> &[T] {
- self.index(&(0..(self.len() - 1)))
+ &self[..self.len() - 1]
}
#[inline]
#[inline]
fn starts_with(&self, needle: &[T]) -> bool where T: PartialEq {
let n = needle.len();
- self.len() >= n && needle == self.index(&(0..n))
+ self.len() >= n && needle == &self[..n]
}
#[inline]
fn ends_with(&self, needle: &[T]) -> bool where T: PartialEq {
let (m, n) = (self.len(), needle.len());
- m >= n && needle == self.index(&((m-n)..))
+ m >= n && needle == &self[m-n..]
}
#[unstable]
self.binary_search_by(|p| p.cmp(x))
}
- #[experimental]
+ #[unstable]
fn next_permutation(&mut self) -> bool where T: Ord {
// These cases only have 1 permutation each, so we can't do anything.
if self.len() < 2 { return false; }
true
}
- #[experimental]
+ #[unstable]
fn prev_permutation(&mut self) -> bool where T: Ord {
// These cases only have 1 permutation each, so we can't do anything.
if self.len() < 2 { return false; }
////////////////////////////////////////////////////////////////////////////////
/// Data that is viewable as a slice.
-#[experimental = "will be replaced by slice syntax"]
+#[unstable = "will be replaced by slice syntax"]
pub trait AsSlice<T> {
/// Work with `self` as a slice.
fn as_slice<'a>(&'a self) -> &'a [T];
}
-#[experimental = "trait is experimental"]
+#[unstable = "trait is experimental"]
impl<T> AsSlice<T> for [T] {
#[inline(always)]
fn as_slice<'a>(&'a self) -> &'a [T] { self }
}
-#[experimental = "trait is experimental"]
+#[unstable = "trait is experimental"]
impl<'a, T, U: ?Sized + AsSlice<T>> AsSlice<T> for &'a U {
#[inline(always)]
fn as_slice(&self) -> &[T] { AsSlice::as_slice(*self) }
}
-#[experimental = "trait is experimental"]
+#[unstable = "trait is experimental"]
impl<'a, T, U: ?Sized + AsSlice<T>> AsSlice<T> for &'a mut U {
#[inline(always)]
fn as_slice(&self) -> &[T] { AsSlice::as_slice(*self) }
marker: marker::ContravariantLifetime<'a>
}
-#[experimental]
+#[unstable]
impl<'a, T> ops::Index<ops::Range<uint>> for Iter<'a, T> {
type Output = [T];
#[inline]
}
}
-#[experimental]
+#[unstable]
impl<'a, T> ops::Index<ops::RangeTo<uint>> for Iter<'a, T> {
type Output = [T];
#[inline]
}
}
-#[experimental]
+#[unstable]
impl<'a, T> ops::Index<ops::RangeFrom<uint>> for Iter<'a, T> {
type Output = [T];
#[inline]
}
}
-#[experimental]
+#[unstable]
impl<'a, T> ops::Index<ops::FullRange> for Iter<'a, T> {
type Output = [T];
#[inline]
///
/// This has the same lifetime as the original slice, and so the
/// iterator can continue to be used while this exists.
- #[experimental]
+ #[unstable]
pub fn as_slice(&self) -> &'a [T] {
make_slice!(T => &'a [T]: self.ptr, self.end)
}
fn clone(&self) -> Iter<'a, T> { *self }
}
-#[experimental = "trait is experimental"]
+#[unstable = "trait is experimental"]
impl<'a, T> RandomAccessIterator for Iter<'a, T> {
#[inline]
fn indexable(&self) -> uint {
}
-#[experimental]
+#[unstable]
impl<'a, T> ops::Index<ops::Range<uint>> for IterMut<'a, T> {
type Output = [T];
#[inline]
self.index(&ops::FullRange).index(index)
}
}
-#[experimental]
+#[unstable]
impl<'a, T> ops::Index<ops::RangeTo<uint>> for IterMut<'a, T> {
type Output = [T];
#[inline]
self.index(&ops::FullRange).index(index)
}
}
-#[experimental]
+#[unstable]
impl<'a, T> ops::Index<ops::RangeFrom<uint>> for IterMut<'a, T> {
type Output = [T];
#[inline]
self.index(&ops::FullRange).index(index)
}
}
-#[experimental]
+#[unstable]
impl<'a, T> ops::Index<ops::FullRange> for IterMut<'a, T> {
type Output = [T];
#[inline]
}
}
-#[experimental]
+#[unstable]
impl<'a, T> ops::IndexMut<ops::Range<uint>> for IterMut<'a, T> {
type Output = [T];
#[inline]
self.index_mut(&ops::FullRange).index_mut(index)
}
}
-#[experimental]
+#[unstable]
impl<'a, T> ops::IndexMut<ops::RangeTo<uint>> for IterMut<'a, T> {
type Output = [T];
#[inline]
self.index_mut(&ops::FullRange).index_mut(index)
}
}
-#[experimental]
+#[unstable]
impl<'a, T> ops::IndexMut<ops::RangeFrom<uint>> for IterMut<'a, T> {
type Output = [T];
#[inline]
self.index_mut(&ops::FullRange).index_mut(index)
}
}
-#[experimental]
+#[unstable]
impl<'a, T> ops::IndexMut<ops::FullRange> for IterMut<'a, T> {
type Output = [T];
#[inline]
/// to consume the iterator. Consider using the `Slice` and
/// `SliceMut` implementations for obtaining slices with more
/// restricted lifetimes that do not consume the iterator.
- #[experimental]
+ #[unstable]
pub fn into_slice(self) -> &'a mut [T] {
make_slice!(T => &'a mut [T]: self.ptr, self.end)
}
match self.v.iter().position(|x| (self.pred)(x)) {
None => self.finish(),
Some(idx) => {
- let ret = Some(self.v.index(&(0..idx)));
- self.v = self.v.index(&((idx + 1)..));
+ let ret = Some(&self.v[..idx]);
+ self.v = &self.v[idx + 1..];
ret
}
}
match self.v.iter().rposition(|x| (self.pred)(x)) {
None => self.finish(),
Some(idx) => {
- let ret = Some(self.v.index(&((idx + 1)..)));
- self.v = self.v.index(&(0..idx));
+ let ret = Some(&self.v[idx + 1..]);
+ self.v = &self.v[..idx];
ret
}
}
if self.size > self.v.len() {
None
} else {
- let ret = Some(self.v.index(&(0..self.size)));
- self.v = self.v.index(&(1..));
+ let ret = Some(&self.v[..self.size]);
+ self.v = &self.v[1..];
ret
}
}
}
}
-#[experimental = "trait is experimental"]
+#[unstable = "trait is experimental"]
impl<'a, T> RandomAccessIterator for Chunks<'a, T> {
#[inline]
fn indexable(&self) -> uint {
let mut hi = lo + self.size;
if hi < lo || hi > self.v.len() { hi = self.v.len(); }
- Some(self.v.index(&(lo..hi)))
+ Some(&self.v[lo..hi])
} else {
None
}
//
/// Operations on `[u8]`.
-#[experimental = "needs review"]
+#[unstable = "needs review"]
pub mod bytes {
use ptr;
use slice::SliceExt;
impl MutableByteVector for [u8] {
#[inline]
- #[allow(experimental)]
+ #[allow(unstable)]
fn set_memory(&mut self, value: u8) {
unsafe { ptr::set_memory(self.as_mut_ptr(), value, self.len()) };
}
}
/// Extension methods for slices containing integers.
-#[experimental]
+#[unstable]
pub trait IntSliceExt<U, S> {
/// Converts the slice to an immutable slice of unsigned integers with the same width.
fn as_unsigned<'a>(&'a self) -> &'a [U];
macro_rules! impl_int_slice {
($u:ty, $s:ty, $t:ty) => {
- #[experimental]
+ #[unstable]
impl IntSliceExt<$u, $s> for [$t] {
#[inline]
fn as_unsigned(&self) -> &[$u] { unsafe { transmute(self) } }