From 121f6c66734301c1d29014f2ef0b58f21fcf1811 Mon Sep 17 00:00:00 2001 From: Aaron Turon Date: Sun, 4 Jan 2015 15:53:00 -0800 Subject: [PATCH] Final alpha stabilization of std::slice Marks as `#[stable]`: * Various iterator structs for stable methods, e.g. `Chunks` and `Windows`. * The `SliceExt` trait itself. --- src/libcollections/slice.rs | 6 ++++-- src/libcore/slice.rs | 12 ++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/libcollections/slice.rs b/src/libcollections/slice.rs index 3602bfc10c3..ceccca561ae 100644 --- a/src/libcollections/slice.rs +++ b/src/libcollections/slice.rs @@ -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}; @@ -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 @@ -699,7 +701,7 @@ pub trait SliceExt for Sized? { fn into_vec(self: Box) -> Vec; } -#[unstable = "trait is unstable"] +#[stable] impl SliceExt for [T] { type Item = T; diff --git a/src/libcore/slice.rs b/src/libcore/slice.rs index f17a775cf42..8174596e65e 100644 --- a/src/libcore/slice.rs +++ b/src/libcore/slice.rs @@ -1083,6 +1083,7 @@ impl> Iterator for GenericSplitN { /// 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> } @@ -1090,12 +1091,14 @@ pub struct SplitN<'a, T: 'a, P> where P: FnMut(&T) -> bool { /// 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> } /// 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> } @@ -1103,6 +1106,7 @@ pub struct SplitNMut<'a, T: 'a, P> where P: FnMut(&T) -> bool { /// 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> } @@ -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 @@ -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 @@ -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 @@ -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 }) }