Skip to content

Commit

Permalink
Stabilize Iterator::intersperse()
Browse files Browse the repository at this point in the history
  • Loading branch information
inquisitivecrystal committed Aug 31, 2021
1 parent 0a84708 commit 06dd4c0
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 20 deletions.
12 changes: 6 additions & 6 deletions library/core/src/iter/adapters/intersperse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use super::Peekable;
///
/// This `struct` is created by [`Iterator::intersperse`]. See its documentation
/// for more information.
#[unstable(feature = "iter_intersperse", reason = "recently added", issue = "79524")]
#[stable(feature = "iter_intersperse", since = "1.56.0")]
#[derive(Debug, Clone)]
pub struct Intersperse<I: Iterator>
where
Expand All @@ -24,7 +24,7 @@ where
}
}

#[unstable(feature = "iter_intersperse", reason = "recently added", issue = "79524")]
#[stable(feature = "iter_intersperse", since = "1.56.0")]
impl<I> Iterator for Intersperse<I>
where
I: Iterator,
Expand Down Expand Up @@ -61,7 +61,7 @@ where
///
/// This `struct` is created by [`Iterator::intersperse_with`]. See its
/// documentation for more information.
#[unstable(feature = "iter_intersperse", reason = "recently added", issue = "79524")]
#[stable(feature = "iter_intersperse", since = "1.56.0")]
pub struct IntersperseWith<I, G>
where
I: Iterator,
Expand All @@ -71,7 +71,7 @@ where
needs_sep: bool,
}

#[unstable(feature = "iter_intersperse", reason = "recently added", issue = "79524")]
#[stable(feature = "iter_intersperse", since = "1.56.0")]
impl<I, G> crate::fmt::Debug for IntersperseWith<I, G>
where
I: Iterator + crate::fmt::Debug,
Expand All @@ -87,7 +87,7 @@ where
}
}

#[unstable(feature = "iter_intersperse", reason = "recently added", issue = "79524")]
#[stable(feature = "iter_intersperse", since = "1.56.0")]
impl<I, G> crate::clone::Clone for IntersperseWith<I, G>
where
I: Iterator + crate::clone::Clone,
Expand All @@ -113,7 +113,7 @@ where
}
}

#[unstable(feature = "iter_intersperse", reason = "recently added", issue = "79524")]
#[stable(feature = "iter_intersperse", since = "1.56.0")]
impl<I, G> Iterator for IntersperseWith<I, G>
where
I: Iterator,
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/iter/adapters/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub use self::flatten::Flatten;
#[stable(feature = "iter_copied", since = "1.36.0")]
pub use self::copied::Copied;

#[unstable(feature = "iter_intersperse", reason = "recently added", issue = "79524")]
#[stable(feature = "iter_intersperse", since = "1.56.0")]
pub use self::intersperse::{Intersperse, IntersperseWith};

#[unstable(feature = "iter_map_while", reason = "recently added", issue = "68537")]
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/iter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ pub use self::adapters::{
Chain, Cycle, Enumerate, Filter, FilterMap, FlatMap, Fuse, Inspect, Map, Peekable, Rev, Scan,
Skip, SkipWhile, Take, TakeWhile, Zip,
};
#[unstable(feature = "iter_intersperse", reason = "recently added", issue = "79524")]
#[stable(feature = "iter_intersperse", since = "1.56.0")]
pub use self::adapters::{Intersperse, IntersperseWith};

pub(crate) use self::adapters::process_results;
Expand Down
14 changes: 4 additions & 10 deletions library/core/src/iter/traits/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -535,8 +535,6 @@ pub trait Iterator {
/// Basic usage:
///
/// ```
/// #![feature(iter_intersperse)]
///
/// let mut a = [0, 1, 2].iter().intersperse(&100);
/// assert_eq!(a.next(), Some(&0)); // The first element from `a`.
/// assert_eq!(a.next(), Some(&100)); // The separator.
Expand All @@ -547,17 +545,16 @@ pub trait Iterator {
/// ```
///
/// `intersperse` can be very useful to join an iterator's items using a common element:
/// ```
/// #![feature(iter_intersperse)]
///
/// ```
/// let hello = ["Hello", "World", "!"].iter().copied().intersperse(" ").collect::<String>();
/// assert_eq!(hello, "Hello World !");
/// ```
///
/// [`Clone`]: crate::clone::Clone
/// [`intersperse_with`]: Iterator::intersperse_with
#[inline]
#[unstable(feature = "iter_intersperse", reason = "recently added", issue = "79524")]
#[stable(feature = "iter_intersperse", since = "1.56.0")]
fn intersperse(self, separator: Self::Item) -> Intersperse<Self>
where
Self: Sized,
Expand All @@ -582,8 +579,6 @@ pub trait Iterator {
/// Basic usage:
///
/// ```
/// #![feature(iter_intersperse)]
///
/// #[derive(PartialEq, Debug)]
/// struct NotClone(usize);
///
Expand All @@ -600,9 +595,8 @@ pub trait Iterator {
///
/// `intersperse_with` can be used in situations where the separator needs
/// to be computed:
/// ```
/// #![feature(iter_intersperse)]
///
/// ```
/// let src = ["Hello", "to", "all", "people", "!!"].iter().copied();
///
/// // The closure mutably borrows its context to generate an item.
Expand All @@ -615,7 +609,7 @@ pub trait Iterator {
/// [`Clone`]: crate::clone::Clone
/// [`intersperse`]: Iterator::intersperse
#[inline]
#[unstable(feature = "iter_intersperse", reason = "recently added", issue = "79524")]
#[stable(feature = "iter_intersperse", since = "1.56.0")]
fn intersperse_with<G>(self, separator: G) -> IntersperseWith<Self, G>
where
Self: Sized,
Expand Down
1 change: 0 additions & 1 deletion library/core/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
#![feature(int_log)]
#![feature(iter_advance_by)]
#![feature(iter_partition_in_place)]
#![feature(iter_intersperse)]
#![feature(iter_is_partitioned)]
#![feature(iter_order_by)]
#![feature(iter_map_while)]
Expand Down
1 change: 0 additions & 1 deletion src/librustdoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#![feature(never_type)]
#![feature(once_cell)]
#![feature(type_ascription)]
#![feature(iter_intersperse)]
#![recursion_limit = "256"]
#![warn(rustc::internal)]

Expand Down

0 comments on commit 06dd4c0

Please sign in to comment.