/// Extension methods for slices.
#[allow(missing_docs)] // docs in libcollections
#[doc(hidden)]
+#[unstable(feature = "core_slice_ext",
+ reason = "stable interface provided by `impl [T]` in later crates")]
pub trait SliceExt {
type Item;
}};
}
-#[unstable(feature = "core")]
impl<T> SliceExt for [T] {
type Item = T;
self.repr().data
}
- #[unstable(feature = "core")]
fn binary_search_by<F>(&self, mut f: F) -> Result<usize, usize> where
F: FnMut(&T) -> Ordering
{
m >= n && needle == &self[m-n..]
}
- #[unstable(feature = "core")]
fn binary_search(&self, x: &T) -> Result<usize, usize> where T: Ord {
self.binary_search_by(|p| p.cmp(x))
}
- #[unstable(feature = "core")]
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
}
- #[unstable(feature = "core")]
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; }
///
/// This has the same lifetime as the original slice, and so the
/// iterator can continue to be used while this exists.
- #[unstable(feature = "core")]
+ #[unstable(feature = "iter_to_slice")]
pub fn as_slice(&self) -> &'a [T] {
make_slice!(self.ptr, self.end)
}
fn clone(&self) -> Iter<'a, T> { Iter { ptr: self.ptr, end: self.end, _marker: self._marker } }
}
-#[unstable(feature = "core", reason = "trait is experimental")]
+#[unstable(feature = "iter_idx", reason = "trait is experimental")]
impl<'a, T> RandomAccessIterator for Iter<'a, T> {
#[inline]
fn indexable(&self) -> usize {
/// to consume the iterator. Consider using the `Slice` and
/// `SliceMut` implementations for obtaining slices with more
/// restricted lifetimes that do not consume the iterator.
- #[unstable(feature = "core")]
+ #[unstable(feature = "iter_to_slice")]
pub fn into_slice(self) -> &'a mut [T] {
make_mut_slice!(self.ptr, self.end)
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, T> ExactSizeIterator for Windows<'a, T> {}
-#[unstable(feature = "core", reason = "trait is experimental")]
+#[unstable(feature = "iter_idx", reason = "trait is experimental")]
impl<'a, T> RandomAccessIterator for Windows<'a, T> {
#[inline]
fn indexable(&self) -> usize {
#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, T> ExactSizeIterator for Chunks<'a, T> {}
-#[unstable(feature = "core", reason = "trait is experimental")]
+#[unstable(feature = "iter_idx", reason = "trait is experimental")]
impl<'a, T> RandomAccessIterator for Chunks<'a, T> {
#[inline]
fn indexable(&self) -> usize {
//
/// Converts a pointer to A into a slice of length 1 (without copying).
-#[unstable(feature = "core")]
+#[unstable(feature = "ref_slice")]
pub fn ref_slice<'a, A>(s: &'a A) -> &'a [A] {
unsafe {
from_raw_parts(s, 1)
}
/// Converts a pointer to A into a slice of length 1 (without copying).
-#[unstable(feature = "core")]
+#[unstable(feature = "ref_slice")]
pub fn mut_ref_slice<'a, A>(s: &'a mut A) -> &'a mut [A] {
unsafe {
from_raw_parts_mut(s, 1)
//
/// Operations on `[u8]`.
-#[unstable(feature = "core", reason = "needs review")]
+#[unstable(feature = "slice_bytes", reason = "needs review")]
pub mod bytes {
use ptr;
use slice::SliceExt;
}
/// Extension methods for slices containing integers.
-#[unstable(feature = "core")]
+#[unstable(feature = "int_slice")]
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) => {
- #[unstable(feature = "core")]
+ #[unstable(feature = "int_slice")]
impl IntSliceExt<$u, $s> for [$t] {
#[inline]
fn as_unsigned(&self) -> &[$u] { unsafe { transmute(self) } }