stabilize slice_rsplit feature

This commit is contained in:
tinaun
2018-04-17 00:30:06 -04:00
parent 94516c5038
commit edc412c5a9
4 changed files with 17 additions and 33 deletions

View File

@@ -1,10 +0,0 @@
# `slice_rsplit`
The tracking issue for this feature is: [#41020]
[#41020]: https://github.com/rust-lang/rust/issues/41020
------------------------
The `slice_rsplit` feature enables two methods on slices:
`slice.rsplit(predicate)` and `slice.rsplit_mut(predicate)`.

View File

@@ -108,7 +108,6 @@
#![feature(ptr_offset_from)] #![feature(ptr_offset_from)]
#![feature(rustc_attrs)] #![feature(rustc_attrs)]
#![feature(slice_get_slice)] #![feature(slice_get_slice)]
#![feature(slice_rsplit)]
#![feature(specialization)] #![feature(specialization)]
#![feature(staged_api)] #![feature(staged_api)]
#![feature(str_internals)] #![feature(str_internals)]

View File

@@ -116,7 +116,7 @@ pub use core::slice::{Iter, IterMut};
pub use core::slice::{SplitMut, ChunksMut, Split}; pub use core::slice::{SplitMut, ChunksMut, Split};
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
pub use core::slice::{SplitN, RSplitN, SplitNMut, RSplitNMut}; pub use core::slice::{SplitN, RSplitN, SplitNMut, RSplitNMut};
#[unstable(feature = "slice_rsplit", issue = "41020")] #[stable(feature = "slice_rsplit", since = "1.27.0")]
pub use core::slice::{RSplit, RSplitMut}; pub use core::slice::{RSplit, RSplitMut};
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
pub use core::slice::{from_raw_parts, from_raw_parts_mut}; pub use core::slice::{from_raw_parts, from_raw_parts_mut};
@@ -888,7 +888,6 @@ impl<T> [T] {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(slice_rsplit)]
/// ///
/// let slice = [11, 22, 33, 0, 44, 55]; /// let slice = [11, 22, 33, 0, 44, 55];
/// let mut iter = slice.rsplit(|num| *num == 0); /// let mut iter = slice.rsplit(|num| *num == 0);
@@ -902,8 +901,6 @@ impl<T> [T] {
/// slice will be the first (or last) item returned by the iterator. /// slice will be the first (or last) item returned by the iterator.
/// ///
/// ``` /// ```
/// #![feature(slice_rsplit)]
///
/// let v = &[0, 1, 1, 2, 3, 5, 8]; /// let v = &[0, 1, 1, 2, 3, 5, 8];
/// let mut it = v.rsplit(|n| *n % 2 == 0); /// let mut it = v.rsplit(|n| *n % 2 == 0);
/// assert_eq!(it.next().unwrap(), &[]); /// assert_eq!(it.next().unwrap(), &[]);
@@ -912,7 +909,7 @@ impl<T> [T] {
/// assert_eq!(it.next().unwrap(), &[]); /// assert_eq!(it.next().unwrap(), &[]);
/// assert_eq!(it.next(), None); /// assert_eq!(it.next(), None);
/// ``` /// ```
#[unstable(feature = "slice_rsplit", issue = "41020")] #[stable(feature = "slice_rsplit", since = "1.27.0")]
#[inline] #[inline]
pub fn rsplit<F>(&self, pred: F) -> RSplit<T, F> pub fn rsplit<F>(&self, pred: F) -> RSplit<T, F>
where F: FnMut(&T) -> bool where F: FnMut(&T) -> bool
@@ -927,8 +924,6 @@ impl<T> [T] {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(slice_rsplit)]
///
/// let mut v = [100, 400, 300, 200, 600, 500]; /// let mut v = [100, 400, 300, 200, 600, 500];
/// ///
/// let mut count = 0; /// let mut count = 0;
@@ -939,7 +934,7 @@ impl<T> [T] {
/// assert_eq!(v, [3, 400, 300, 2, 600, 1]); /// assert_eq!(v, [3, 400, 300, 2, 600, 1]);
/// ``` /// ```
/// ///
#[unstable(feature = "slice_rsplit", issue = "41020")] #[stable(feature = "slice_rsplit", since = "1.27.0")]
#[inline] #[inline]
pub fn rsplit_mut<F>(&mut self, pred: F) -> RSplitMut<T, F> pub fn rsplit_mut<F>(&mut self, pred: F) -> RSplitMut<T, F>
where F: FnMut(&T) -> bool where F: FnMut(&T) -> bool

View File

@@ -86,7 +86,7 @@ pub trait SliceExt {
fn split<P>(&self, pred: P) -> Split<Self::Item, P> fn split<P>(&self, pred: P) -> Split<Self::Item, P>
where P: FnMut(&Self::Item) -> bool; where P: FnMut(&Self::Item) -> bool;
#[unstable(feature = "slice_rsplit", issue = "41020")] #[stable(feature = "slice_rsplit", since = "1.27.0")]
fn rsplit<P>(&self, pred: P) -> RSplit<Self::Item, P> fn rsplit<P>(&self, pred: P) -> RSplit<Self::Item, P>
where P: FnMut(&Self::Item) -> bool; where P: FnMut(&Self::Item) -> bool;
@@ -169,7 +169,7 @@ pub trait SliceExt {
fn split_mut<P>(&mut self, pred: P) -> SplitMut<Self::Item, P> fn split_mut<P>(&mut self, pred: P) -> SplitMut<Self::Item, P>
where P: FnMut(&Self::Item) -> bool; where P: FnMut(&Self::Item) -> bool;
#[unstable(feature = "slice_rsplit", issue = "41020")] #[stable(feature = "slice_rsplit", since = "1.27.0")]
fn rsplit_mut<P>(&mut self, pred: P) -> RSplitMut<Self::Item, P> fn rsplit_mut<P>(&mut self, pred: P) -> RSplitMut<Self::Item, P>
where P: FnMut(&Self::Item) -> bool; where P: FnMut(&Self::Item) -> bool;
@@ -1840,13 +1840,13 @@ impl<'a, T, P> FusedIterator for SplitMut<'a, T, P> where P: FnMut(&T) -> bool {
/// ///
/// [`rsplit`]: ../../std/primitive.slice.html#method.rsplit /// [`rsplit`]: ../../std/primitive.slice.html#method.rsplit
/// [slices]: ../../std/primitive.slice.html /// [slices]: ../../std/primitive.slice.html
#[unstable(feature = "slice_rsplit", issue = "41020")] #[stable(feature = "slice_rsplit", since = "1.27.0")]
#[derive(Clone)] // Is this correct, or does it incorrectly require `T: Clone`? #[derive(Clone)] // Is this correct, or does it incorrectly require `T: Clone`?
pub struct RSplit<'a, T:'a, P> where P: FnMut(&T) -> bool { pub struct RSplit<'a, T:'a, P> where P: FnMut(&T) -> bool {
inner: Split<'a, T, P> inner: Split<'a, T, P>
} }
#[unstable(feature = "slice_rsplit", issue = "41020")] #[stable(feature = "slice_rsplit", since = "1.27.0")]
impl<'a, T: 'a + fmt::Debug, P> fmt::Debug for RSplit<'a, T, P> where P: FnMut(&T) -> bool { impl<'a, T: 'a + fmt::Debug, P> fmt::Debug for RSplit<'a, T, P> where P: FnMut(&T) -> bool {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("RSplit") f.debug_struct("RSplit")
@@ -1856,7 +1856,7 @@ impl<'a, T: 'a + fmt::Debug, P> fmt::Debug for RSplit<'a, T, P> where P: FnMut(&
} }
} }
#[unstable(feature = "slice_rsplit", issue = "41020")] #[stable(feature = "slice_rsplit", since = "1.27.0")]
impl<'a, T, P> Iterator for RSplit<'a, T, P> where P: FnMut(&T) -> bool { impl<'a, T, P> Iterator for RSplit<'a, T, P> where P: FnMut(&T) -> bool {
type Item = &'a [T]; type Item = &'a [T];
@@ -1871,7 +1871,7 @@ impl<'a, T, P> Iterator for RSplit<'a, T, P> where P: FnMut(&T) -> bool {
} }
} }
#[unstable(feature = "slice_rsplit", issue = "41020")] #[stable(feature = "slice_rsplit", since = "1.27.0")]
impl<'a, T, P> DoubleEndedIterator for RSplit<'a, T, P> where P: FnMut(&T) -> bool { impl<'a, T, P> DoubleEndedIterator for RSplit<'a, T, P> where P: FnMut(&T) -> bool {
#[inline] #[inline]
fn next_back(&mut self) -> Option<&'a [T]> { fn next_back(&mut self) -> Option<&'a [T]> {
@@ -1879,7 +1879,7 @@ impl<'a, T, P> DoubleEndedIterator for RSplit<'a, T, P> where P: FnMut(&T) -> bo
} }
} }
#[unstable(feature = "slice_rsplit", issue = "41020")] #[stable(feature = "slice_rsplit", since = "1.27.0")]
impl<'a, T, P> SplitIter for RSplit<'a, T, P> where P: FnMut(&T) -> bool { impl<'a, T, P> SplitIter for RSplit<'a, T, P> where P: FnMut(&T) -> bool {
#[inline] #[inline]
fn finish(&mut self) -> Option<&'a [T]> { fn finish(&mut self) -> Option<&'a [T]> {
@@ -1887,7 +1887,7 @@ impl<'a, T, P> SplitIter for RSplit<'a, T, P> where P: FnMut(&T) -> bool {
} }
} }
#[unstable(feature = "slice_rsplit", issue = "41020")] #[stable(feature = "slice_rsplit", since = "1.27.0")]
impl<'a, T, P> FusedIterator for RSplit<'a, T, P> where P: FnMut(&T) -> bool {} impl<'a, T, P> FusedIterator for RSplit<'a, T, P> where P: FnMut(&T) -> bool {}
/// An iterator over the subslices of the vector which are separated /// An iterator over the subslices of the vector which are separated
@@ -1897,12 +1897,12 @@ impl<'a, T, P> FusedIterator for RSplit<'a, T, P> where P: FnMut(&T) -> bool {}
/// ///
/// [`rsplit_mut`]: ../../std/primitive.slice.html#method.rsplit_mut /// [`rsplit_mut`]: ../../std/primitive.slice.html#method.rsplit_mut
/// [slices]: ../../std/primitive.slice.html /// [slices]: ../../std/primitive.slice.html
#[unstable(feature = "slice_rsplit", issue = "41020")] #[stable(feature = "slice_rsplit", since = "1.27.0")]
pub struct RSplitMut<'a, T:'a, P> where P: FnMut(&T) -> bool { pub struct RSplitMut<'a, T:'a, P> where P: FnMut(&T) -> bool {
inner: SplitMut<'a, T, P> inner: SplitMut<'a, T, P>
} }
#[unstable(feature = "slice_rsplit", issue = "41020")] #[stable(feature = "slice_rsplit", since = "1.27.0")]
impl<'a, T: 'a + fmt::Debug, P> fmt::Debug for RSplitMut<'a, T, P> where P: FnMut(&T) -> bool { impl<'a, T: 'a + fmt::Debug, P> fmt::Debug for RSplitMut<'a, T, P> where P: FnMut(&T) -> bool {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("RSplitMut") f.debug_struct("RSplitMut")
@@ -1912,7 +1912,7 @@ impl<'a, T: 'a + fmt::Debug, P> fmt::Debug for RSplitMut<'a, T, P> where P: FnMu
} }
} }
#[unstable(feature = "slice_rsplit", issue = "41020")] #[stable(feature = "slice_rsplit", since = "1.27.0")]
impl<'a, T, P> SplitIter for RSplitMut<'a, T, P> where P: FnMut(&T) -> bool { impl<'a, T, P> SplitIter for RSplitMut<'a, T, P> where P: FnMut(&T) -> bool {
#[inline] #[inline]
fn finish(&mut self) -> Option<&'a mut [T]> { fn finish(&mut self) -> Option<&'a mut [T]> {
@@ -1920,7 +1920,7 @@ impl<'a, T, P> SplitIter for RSplitMut<'a, T, P> where P: FnMut(&T) -> bool {
} }
} }
#[unstable(feature = "slice_rsplit", issue = "41020")] #[stable(feature = "slice_rsplit", since = "1.27.0")]
impl<'a, T, P> Iterator for RSplitMut<'a, T, P> where P: FnMut(&T) -> bool { impl<'a, T, P> Iterator for RSplitMut<'a, T, P> where P: FnMut(&T) -> bool {
type Item = &'a mut [T]; type Item = &'a mut [T];
@@ -1935,7 +1935,7 @@ impl<'a, T, P> Iterator for RSplitMut<'a, T, P> where P: FnMut(&T) -> bool {
} }
} }
#[unstable(feature = "slice_rsplit", issue = "41020")] #[stable(feature = "slice_rsplit", since = "1.27.0")]
impl<'a, T, P> DoubleEndedIterator for RSplitMut<'a, T, P> where impl<'a, T, P> DoubleEndedIterator for RSplitMut<'a, T, P> where
P: FnMut(&T) -> bool, P: FnMut(&T) -> bool,
{ {
@@ -1945,7 +1945,7 @@ impl<'a, T, P> DoubleEndedIterator for RSplitMut<'a, T, P> where
} }
} }
#[unstable(feature = "slice_rsplit", issue = "41020")] #[stable(feature = "slice_rsplit", since = "1.27.0")]
impl<'a, T, P> FusedIterator for RSplitMut<'a, T, P> where P: FnMut(&T) -> bool {} impl<'a, T, P> FusedIterator for RSplitMut<'a, T, P> where P: FnMut(&T) -> bool {}
/// An private iterator over subslices separated by elements that /// An private iterator over subslices separated by elements that