Skip to content

Commit

Permalink
Final alpha stabilization of std::slice
Browse files Browse the repository at this point in the history
Marks as `#[stable]`:

* Various iterator structs for stable methods, e.g. `Chunks` and
  `Windows`.
* The `SliceExt` trait itself.
  • Loading branch information
aturon committed Jan 5, 2015
1 parent e921afd commit 121f6c6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/libcollections/slice.rs
Expand Up @@ -86,6 +86,7 @@
//! * Further iterators exist that split, chunk or permute the slice.

#![doc(primitive = "slice")]
#![stable]

use alloc::boxed::Box;
use core::borrow::{BorrowFrom, BorrowFromMut, ToOwned};
Expand Down Expand Up @@ -119,8 +120,9 @@ pub use core::slice::{from_raw_buf, from_raw_mut_buf};
////////////////////////////////////////////////////////////////////////////////

/// Allocating extension methods for slices.
#[unstable = "needs associated types, may merge with other traits"]
#[stable]
pub trait SliceExt for Sized? {
#[stable]
type Item;

/// Sorts the slice, in place, using `compare` to compare
Expand Down Expand Up @@ -699,7 +701,7 @@ pub trait SliceExt for Sized? {
fn into_vec(self: Box<Self>) -> Vec<Self::Item>;
}

#[unstable = "trait is unstable"]
#[stable]
impl<T> SliceExt for [T] {
type Item = T;

Expand Down
12 changes: 8 additions & 4 deletions src/libcore/slice.rs
Expand Up @@ -1083,26 +1083,30 @@ impl<T, I: SplitIter + Iterator<Item=T>> Iterator for GenericSplitN<I> {

/// An iterator over subslices separated by elements that match a predicate
/// function, limited to a given number of splits.
#[stable]
pub struct SplitN<'a, T: 'a, P> where P: FnMut(&T) -> bool {
inner: GenericSplitN<Split<'a, T, P>>
}

/// An iterator over subslices separated by elements that match a
/// predicate function, limited to a given number of splits, starting
/// from the end of the slice.
#[stable]
pub struct RSplitN<'a, T: 'a, P> where P: FnMut(&T) -> bool {
inner: GenericSplitN<Split<'a, T, P>>
}

/// An iterator over subslices separated by elements that match a predicate
/// function, limited to a given number of splits.
#[stable]
pub struct SplitNMut<'a, T: 'a, P> where P: FnMut(&T) -> bool {
inner: GenericSplitN<SplitMut<'a, T, P>>
}

/// An iterator over subslices separated by elements that match a
/// predicate function, limited to a given number of splits, starting
/// from the end of the slice.
#[stable]
pub struct RSplitNMut<'a, T: 'a, P> where P: FnMut(&T) -> bool {
inner: GenericSplitN<SplitMut<'a, T, P>>
}
Expand Down Expand Up @@ -1134,7 +1138,7 @@ forward_iterator! { RSplitNMut: T, &'a mut [T] }

/// An iterator over overlapping subslices of length `size`.
#[derive(Clone)]
#[experimental = "needs review"]
#[stable]
pub struct Windows<'a, T:'a> {
v: &'a [T],
size: uint
Expand Down Expand Up @@ -1171,7 +1175,7 @@ impl<'a, T> Iterator for Windows<'a, T> {
/// When the slice len is not evenly divided by the chunk size, the last slice
/// of the iteration will be the remainder.
#[derive(Clone)]
#[experimental = "needs review"]
#[stable]
pub struct Chunks<'a, T:'a> {
v: &'a [T],
size: uint
Expand Down Expand Up @@ -1246,7 +1250,7 @@ impl<'a, T> RandomAccessIterator for Chunks<'a, T> {
/// An iterator over a slice in (non-overlapping) mutable chunks (`size`
/// elements at a time). When the slice len is not evenly divided by the chunk
/// size, the last slice of the iteration will be the remainder.
#[experimental = "needs review"]
#[stable]
pub struct ChunksMut<'a, T:'a> {
v: &'a mut [T],
chunk_size: uint
Expand Down Expand Up @@ -1360,7 +1364,7 @@ pub unsafe fn from_raw_buf<'a, T>(p: &'a *const T, len: uint) -> &'a [T] {
/// not being able to provide a non-aliasing guarantee of the returned mutable
/// slice.
#[inline]
#[unstable = "jshould be renamed to from_raw_parts_mut"]
#[unstable = "should be renamed to from_raw_parts_mut"]
pub unsafe fn from_raw_mut_buf<'a, T>(p: &'a *mut T, len: uint) -> &'a mut [T] {
transmute(RawSlice { data: *p as *const T, len: len })
}
Expand Down

0 comments on commit 121f6c6

Please sign in to comment.