From 95d27959076836a70f28eb4fef217f93dd040e2d Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Tue, 19 Feb 2019 13:58:55 +0100 Subject: [PATCH 1/2] Stabilize iter::successors FCP: https://github.com/rust-lang/rust/issues/58045#issuecomment-464674773 --- src/libcore/iter/mod.rs | 4 +++- src/libcore/iter/sources.rs | 11 +++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/libcore/iter/mod.rs b/src/libcore/iter/mod.rs index 4e1dc108cc9bd..204c36a757169 100644 --- a/src/libcore/iter/mod.rs +++ b/src/libcore/iter/mod.rs @@ -327,7 +327,9 @@ pub use self::sources::{Once, once}; #[unstable(feature = "iter_once_with", issue = "57581")] pub use self::sources::{OnceWith, once_with}; #[unstable(feature = "iter_unfold", issue = "55977")] -pub use self::sources::{FromFn, from_fn, Successors, successors}; +pub use self::sources::{FromFn, from_fn}; +#[stable(feature = "iter_successors", since = "1.34.0")] +pub use self::sources::{Successors, successors}; #[stable(feature = "rust1", since = "1.0.0")] pub use self::traits::{FromIterator, IntoIterator, DoubleEndedIterator, Extend}; diff --git a/src/libcore/iter/sources.rs b/src/libcore/iter/sources.rs index 6f45f082d6a37..359cf24ec57d8 100644 --- a/src/libcore/iter/sources.rs +++ b/src/libcore/iter/sources.rs @@ -572,13 +572,12 @@ impl fmt::Debug for FromFn { /// and calls the given `FnMut(&T) -> Option` closure to compute each item’s successor. /// /// ``` -/// #![feature(iter_unfold)] /// use std::iter::successors; /// /// let powers_of_10 = successors(Some(1_u16), |n| n.checked_mul(10)); /// assert_eq!(powers_of_10.collect::>(), &[1, 10, 100, 1_000, 10_000]); /// ``` -#[unstable(feature = "iter_unfold", issue = "55977")] +#[stable(feature = "iter_successors", since = "1.34.0")] pub fn successors(first: Option, succ: F) -> Successors where F: FnMut(&T) -> Option { @@ -598,13 +597,13 @@ pub fn successors(first: Option, succ: F) -> Successors /// /// [`successors`]: fn.successors.html #[derive(Clone)] -#[unstable(feature = "iter_unfold", issue = "55977")] +#[stable(feature = "iter_successors", since = "1.34.0")] pub struct Successors { next: Option, succ: F, } -#[unstable(feature = "iter_unfold", issue = "55977")] +#[stable(feature = "iter_successors", since = "1.34.0")] impl Iterator for Successors where F: FnMut(&T) -> Option { @@ -628,12 +627,12 @@ impl Iterator for Successors } } -#[unstable(feature = "iter_unfold", issue = "55977")] +#[stable(feature = "iter_successors", since = "1.34.0")] impl FusedIterator for Successors where F: FnMut(&T) -> Option {} -#[unstable(feature = "iter_unfold", issue = "55977")] +#[stable(feature = "iter_successors", since = "1.34.0")] impl fmt::Debug for Successors { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("Successors") From 3906cb9187d92a39435086de113ab67b6dd9ba43 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Tue, 19 Feb 2019 14:10:07 +0100 Subject: [PATCH 2/2] Stabilize iter::from_fn FCP: https://github.com/rust-lang/rust/issues/55977#issuecomment-463964234 --- src/libcore/iter/mod.rs | 2 +- src/libcore/iter/sources.rs | 9 ++++----- src/libcore/tests/lib.rs | 1 - 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/libcore/iter/mod.rs b/src/libcore/iter/mod.rs index 204c36a757169..5dcca7ee0ca01 100644 --- a/src/libcore/iter/mod.rs +++ b/src/libcore/iter/mod.rs @@ -326,7 +326,7 @@ pub use self::sources::{Empty, empty}; pub use self::sources::{Once, once}; #[unstable(feature = "iter_once_with", issue = "57581")] pub use self::sources::{OnceWith, once_with}; -#[unstable(feature = "iter_unfold", issue = "55977")] +#[stable(feature = "iter_from_fn", since = "1.34.0")] pub use self::sources::{FromFn, from_fn}; #[stable(feature = "iter_successors", since = "1.34.0")] pub use self::sources::{Successors, successors}; diff --git a/src/libcore/iter/sources.rs b/src/libcore/iter/sources.rs index 359cf24ec57d8..74ff7f41d76fa 100644 --- a/src/libcore/iter/sources.rs +++ b/src/libcore/iter/sources.rs @@ -514,7 +514,6 @@ pub fn once_with A>(gen: F) -> OnceWith { /// [module-level documentation]: index.html /// /// ``` -/// #![feature(iter_unfold)] /// let mut count = 0; /// let counter = std::iter::from_fn(move || { /// // Increment our count. This is why we started at zero. @@ -530,7 +529,7 @@ pub fn once_with A>(gen: F) -> OnceWith { /// assert_eq!(counter.collect::>(), &[1, 2, 3, 4, 5]); /// ``` #[inline] -#[unstable(feature = "iter_unfold", issue = "55977")] +#[stable(feature = "iter_from_fn", since = "1.34.0")] pub fn from_fn(f: F) -> FromFn where F: FnMut() -> Option { @@ -544,10 +543,10 @@ pub fn from_fn(f: F) -> FromFn /// /// [`iter::from_fn`]: fn.from_fn.html #[derive(Clone)] -#[unstable(feature = "iter_unfold", issue = "55977")] +#[stable(feature = "iter_from_fn", since = "1.34.0")] pub struct FromFn(F); -#[unstable(feature = "iter_unfold", issue = "55977")] +#[stable(feature = "iter_from_fn", since = "1.34.0")] impl Iterator for FromFn where F: FnMut() -> Option { @@ -559,7 +558,7 @@ impl Iterator for FromFn } } -#[unstable(feature = "iter_unfold", issue = "55977")] +#[stable(feature = "iter_from_fn", since = "1.34.0")] impl fmt::Debug for FromFn { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("FromFn").finish() diff --git a/src/libcore/tests/lib.rs b/src/libcore/tests/lib.rs index 3e8549f8ae366..4cd734bad90a4 100644 --- a/src/libcore/tests/lib.rs +++ b/src/libcore/tests/lib.rs @@ -14,7 +14,6 @@ #![feature(iter_copied)] #![feature(iter_nth_back)] #![feature(iter_once_with)] -#![feature(iter_unfold)] #![feature(pattern)] #![feature(range_is_empty)] #![feature(raw)]