Skip to content
Permalink
Browse files

Stabilize iter::from_fn

  • Loading branch information...
SimonSapin committed Feb 19, 2019
1 parent 95d2795 commit 3906cb9187d92a39435086de113ab67b6dd9ba43
Showing with 5 additions and 7 deletions.
  1. +1 −1 src/libcore/iter/mod.rs
  2. +4 −5 src/libcore/iter/sources.rs
  3. +0 −1 src/libcore/tests/lib.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};
@@ -514,7 +514,6 @@ pub fn once_with<A, F: FnOnce() -> A>(gen: F) -> OnceWith<F> {
/// [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, F: FnOnce() -> A>(gen: F) -> OnceWith<F> {
/// assert_eq!(counter.collect::<Vec<_>>(), &[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<T, F>(f: F) -> FromFn<F>
where F: FnMut() -> Option<T>
{
@@ -544,10 +543,10 @@ pub fn from_fn<T, F>(f: F) -> FromFn<F>
///
/// [`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>(F);

#[unstable(feature = "iter_unfold", issue = "55977")]
#[stable(feature = "iter_from_fn", since = "1.34.0")]
impl<T, F> Iterator for FromFn<F>
where F: FnMut() -> Option<T>
{
@@ -559,7 +558,7 @@ impl<T, F> Iterator for FromFn<F>
}
}

#[unstable(feature = "iter_unfold", issue = "55977")]
#[stable(feature = "iter_from_fn", since = "1.34.0")]
impl<F> fmt::Debug for FromFn<F> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_struct("FromFn").finish()
@@ -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)]

0 comments on commit 3906cb9

Please sign in to comment.
You can’t perform that action at this time.