Skip to content

Commit 8ca56e1

Browse files
committed
Rollup merge of #58576 - SimonSapin:successors, r=Centril
Stabilize iter::successors and iter::from_fn FCP: #58045 (comment), #55977 (comment)
2 parents 95daca4 + 3906cb9 commit 8ca56e1

File tree

3 files changed

+13
-14
lines changed

3 files changed

+13
-14
lines changed

src/libcore/iter/mod.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,10 @@ pub use self::sources::{Empty, empty};
326326
pub use self::sources::{Once, once};
327327
#[unstable(feature = "iter_once_with", issue = "57581")]
328328
pub use self::sources::{OnceWith, once_with};
329-
#[unstable(feature = "iter_unfold", issue = "55977")]
330-
pub use self::sources::{FromFn, from_fn, Successors, successors};
329+
#[stable(feature = "iter_from_fn", since = "1.34.0")]
330+
pub use self::sources::{FromFn, from_fn};
331+
#[stable(feature = "iter_successors", since = "1.34.0")]
332+
pub use self::sources::{Successors, successors};
331333

332334
#[stable(feature = "rust1", since = "1.0.0")]
333335
pub use self::traits::{FromIterator, IntoIterator, DoubleEndedIterator, Extend};

src/libcore/iter/sources.rs

+9-11
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,6 @@ pub fn once_with<A, F: FnOnce() -> A>(gen: F) -> OnceWith<F> {
514514
/// [module-level documentation]: index.html
515515
///
516516
/// ```
517-
/// #![feature(iter_unfold)]
518517
/// let mut count = 0;
519518
/// let counter = std::iter::from_fn(move || {
520519
/// // 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> {
530529
/// assert_eq!(counter.collect::<Vec<_>>(), &[1, 2, 3, 4, 5]);
531530
/// ```
532531
#[inline]
533-
#[unstable(feature = "iter_unfold", issue = "55977")]
532+
#[stable(feature = "iter_from_fn", since = "1.34.0")]
534533
pub fn from_fn<T, F>(f: F) -> FromFn<F>
535534
where F: FnMut() -> Option<T>
536535
{
@@ -544,10 +543,10 @@ pub fn from_fn<T, F>(f: F) -> FromFn<F>
544543
///
545544
/// [`iter::from_fn`]: fn.from_fn.html
546545
#[derive(Clone)]
547-
#[unstable(feature = "iter_unfold", issue = "55977")]
546+
#[stable(feature = "iter_from_fn", since = "1.34.0")]
548547
pub struct FromFn<F>(F);
549548

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

562-
#[unstable(feature = "iter_unfold", issue = "55977")]
561+
#[stable(feature = "iter_from_fn", since = "1.34.0")]
563562
impl<F> fmt::Debug for FromFn<F> {
564563
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
565564
f.debug_struct("FromFn").finish()
@@ -572,13 +571,12 @@ impl<F> fmt::Debug for FromFn<F> {
572571
/// and calls the given `FnMut(&T) -> Option<T>` closure to compute each item’s successor.
573572
///
574573
/// ```
575-
/// #![feature(iter_unfold)]
576574
/// use std::iter::successors;
577575
///
578576
/// let powers_of_10 = successors(Some(1_u16), |n| n.checked_mul(10));
579577
/// assert_eq!(powers_of_10.collect::<Vec<_>>(), &[1, 10, 100, 1_000, 10_000]);
580578
/// ```
581-
#[unstable(feature = "iter_unfold", issue = "55977")]
579+
#[stable(feature = "iter_successors", since = "1.34.0")]
582580
pub fn successors<T, F>(first: Option<T>, succ: F) -> Successors<T, F>
583581
where F: FnMut(&T) -> Option<T>
584582
{
@@ -598,13 +596,13 @@ pub fn successors<T, F>(first: Option<T>, succ: F) -> Successors<T, F>
598596
///
599597
/// [`successors`]: fn.successors.html
600598
#[derive(Clone)]
601-
#[unstable(feature = "iter_unfold", issue = "55977")]
599+
#[stable(feature = "iter_successors", since = "1.34.0")]
602600
pub struct Successors<T, F> {
603601
next: Option<T>,
604602
succ: F,
605603
}
606604

607-
#[unstable(feature = "iter_unfold", issue = "55977")]
605+
#[stable(feature = "iter_successors", since = "1.34.0")]
608606
impl<T, F> Iterator for Successors<T, F>
609607
where F: FnMut(&T) -> Option<T>
610608
{
@@ -628,12 +626,12 @@ impl<T, F> Iterator for Successors<T, F>
628626
}
629627
}
630628

631-
#[unstable(feature = "iter_unfold", issue = "55977")]
629+
#[stable(feature = "iter_successors", since = "1.34.0")]
632630
impl<T, F> FusedIterator for Successors<T, F>
633631
where F: FnMut(&T) -> Option<T>
634632
{}
635633

636-
#[unstable(feature = "iter_unfold", issue = "55977")]
634+
#[stable(feature = "iter_successors", since = "1.34.0")]
637635
impl<T: fmt::Debug, F> fmt::Debug for Successors<T, F> {
638636
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
639637
f.debug_struct("Successors")

src/libcore/tests/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#![feature(iter_copied)]
1515
#![feature(iter_nth_back)]
1616
#![feature(iter_once_with)]
17-
#![feature(iter_unfold)]
1817
#![feature(pattern)]
1918
#![feature(range_is_empty)]
2019
#![feature(raw)]

0 commit comments

Comments
 (0)