Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stabilize iterator methods in 1.27 #49607

Merged
merged 3 commits into from
Apr 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/liballoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@
#![feature(fundamental)]
#![feature(generic_param_attrs)]
#![cfg_attr(stage0, feature(i128_type))]
#![feature(iter_rfold)]
#![feature(lang_items)]
#![feature(needs_allocator)]
#![feature(nonzero)]
Expand Down
7 changes: 2 additions & 5 deletions src/libcore/iter/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1446,7 +1446,6 @@ pub trait Iterator {
/// Basic usage:
///
/// ```
/// #![feature(iterator_try_fold)]
/// let a = [1, 2, 3];
///
/// // the checked sum of all of the elements of the array
Expand All @@ -1458,7 +1457,6 @@ pub trait Iterator {
/// Short-circuiting:
///
/// ```
/// #![feature(iterator_try_fold)]
/// let a = [10, 20, 30, 100, 40, 50];
/// let mut it = a.iter();
///
Expand All @@ -1472,7 +1470,7 @@ pub trait Iterator {
/// assert_eq!(it.next(), Some(&40));
/// ```
#[inline]
#[unstable(feature = "iterator_try_fold", issue = "45594")]
#[stable(feature = "iterator_try_fold", since = "1.27.0")]
fn try_fold<B, F, R>(&mut self, init: B, mut f: F) -> R where
Self: Sized, F: FnMut(B, Self::Item) -> R, R: Try<Ok=B>
{
Expand All @@ -1495,7 +1493,6 @@ pub trait Iterator {
/// # Examples
///
/// ```
/// #![feature(iterator_try_fold)]
/// use std::fs::rename;
/// use std::io::{stdout, Write};
/// use std::path::Path;
Expand All @@ -1512,7 +1509,7 @@ pub trait Iterator {
/// assert_eq!(it.next(), Some("stale_bread.json"));
/// ```
#[inline]
#[unstable(feature = "iterator_try_fold", issue = "45594")]
#[stable(feature = "iterator_try_fold", since = "1.27.0")]
fn try_for_each<F, R>(&mut self, mut f: F) -> R where
Self: Sized, F: FnMut(Self::Item) -> R, R: Try<Ok=()>
{
Expand Down
16 changes: 4 additions & 12 deletions src/libcore/iter/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,6 @@ pub trait DoubleEndedIterator: Iterator {
/// Basic usage:
///
/// ```
/// #![feature(iterator_try_fold)]
/// let a = ["1", "2", "3"];
/// let sum = a.iter()
/// .map(|&s| s.parse::<i32>())
Expand All @@ -438,7 +437,6 @@ pub trait DoubleEndedIterator: Iterator {
/// Short-circuiting:
///
/// ```
/// #![feature(iterator_try_fold)]
/// let a = ["1", "rust", "3"];
/// let mut it = a.iter();
/// let sum = it
Expand All @@ -452,7 +450,7 @@ pub trait DoubleEndedIterator: Iterator {
/// assert_eq!(it.next_back(), Some(&"1"));
/// ```
#[inline]
#[unstable(feature = "iterator_try_fold", issue = "45594")]
#[stable(feature = "iterator_try_fold", since = "1.27.0")]
fn try_rfold<B, F, R>(&mut self, init: B, mut f: F) -> R where
Self: Sized, F: FnMut(B, Self::Item) -> R, R: Try<Ok=B>
{
Expand Down Expand Up @@ -491,7 +489,6 @@ pub trait DoubleEndedIterator: Iterator {
/// Basic usage:
///
/// ```
/// #![feature(iter_rfold)]
/// let a = [1, 2, 3];
///
/// // the sum of all of the elements of a
Expand All @@ -505,7 +502,6 @@ pub trait DoubleEndedIterator: Iterator {
/// and continuing with each element from the back until the front:
///
/// ```
/// #![feature(iter_rfold)]
/// let numbers = [1, 2, 3, 4, 5];
///
/// let zero = "0".to_string();
Expand All @@ -517,14 +513,14 @@ pub trait DoubleEndedIterator: Iterator {
/// assert_eq!(result, "(1 + (2 + (3 + (4 + (5 + 0)))))");
/// ```
#[inline]
#[unstable(feature = "iter_rfold", issue = "44705")]
#[stable(feature = "iter_rfold", since = "1.27.0")]
fn rfold<B, F>(mut self, accum: B, mut f: F) -> B where
Self: Sized, F: FnMut(B, Self::Item) -> B,
{
self.try_rfold(accum, move |acc, x| AlwaysOk(f(acc, x))).0
}

/// Searches for an element of an iterator from the right that satisfies a predicate.
/// Searches for an element of an iterator from the back that satisfies a predicate.
///
/// `rfind()` takes a closure that returns `true` or `false`. It applies
/// this closure to each element of the iterator, starting at the end, and if any
Expand All @@ -547,8 +543,6 @@ pub trait DoubleEndedIterator: Iterator {
/// Basic usage:
///
/// ```
/// #![feature(iter_rfind)]
///
/// let a = [1, 2, 3];
///
/// assert_eq!(a.iter().rfind(|&&x| x == 2), Some(&2));
Expand All @@ -559,8 +553,6 @@ pub trait DoubleEndedIterator: Iterator {
/// Stopping at the first `true`:
///
/// ```
/// #![feature(iter_rfind)]
///
/// let a = [1, 2, 3];
///
/// let mut iter = a.iter();
Expand All @@ -571,7 +563,7 @@ pub trait DoubleEndedIterator: Iterator {
/// assert_eq!(iter.next_back(), Some(&1));
/// ```
#[inline]
#[unstable(feature = "iter_rfind", issue = "39480")]
#[stable(feature = "iter_rfind", since = "1.27.0")]
fn rfind<P>(&mut self, mut predicate: P) -> Option<Self::Item> where
Self: Sized,
P: FnMut(&Self::Item) -> bool
Expand Down
3 changes: 0 additions & 3 deletions src/libcore/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,8 @@
#![feature(iterator_step_by)]
#![cfg_attr(stage0, feature(i128_type))]
#![cfg_attr(stage0, feature(inclusive_range_syntax))]
#![feature(iterator_try_fold)]
#![feature(iterator_flatten)]
#![cfg_attr(stage0, feature(conservative_impl_trait))]
#![feature(iter_rfind)]
#![feature(iter_rfold)]
#![feature(iterator_repeat_with)]
#![feature(nonzero)]
#![feature(pattern)]
Expand Down