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

Revert "Stabilize Iterator::intersperse()" #89638

Merged
merged 1 commit into from
Oct 8, 2021
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
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.
#[stable(feature = "iter_intersperse", since = "1.56.0")]
#[unstable(feature = "iter_intersperse", reason = "recently added", issue = "79524")]
#[derive(Debug, Clone)]
pub struct Intersperse<I: Iterator>
where
Expand All @@ -24,7 +24,7 @@ where
}
}

#[stable(feature = "iter_intersperse", since = "1.56.0")]
#[unstable(feature = "iter_intersperse", reason = "recently added", issue = "79524")]
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.
#[stable(feature = "iter_intersperse", since = "1.56.0")]
#[unstable(feature = "iter_intersperse", reason = "recently added", issue = "79524")]
pub struct IntersperseWith<I, G>
where
I: Iterator,
Expand All @@ -71,7 +71,7 @@ where
needs_sep: bool,
}

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

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

#[stable(feature = "iter_intersperse", since = "1.56.0")]
#[unstable(feature = "iter_intersperse", reason = "recently added", issue = "79524")]
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;

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

#[stable(feature = "iter_map_while", since = "1.57.0")]
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,
};
#[stable(feature = "iter_intersperse", since = "1.56.0")]
#[unstable(feature = "iter_intersperse", reason = "recently added", issue = "79524")]
pub use self::adapters::{Intersperse, IntersperseWith};

pub(crate) use self::adapters::process_results;
Expand Down
14 changes: 10 additions & 4 deletions library/core/src/iter/traits/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,8 @@ 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 @@ -549,16 +551,17 @@ 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]
#[stable(feature = "iter_intersperse", since = "1.56.0")]
#[unstable(feature = "iter_intersperse", reason = "recently added", issue = "79524")]
fn intersperse(self, separator: Self::Item) -> Intersperse<Self>
where
Self: Sized,
Expand All @@ -583,6 +586,8 @@ pub trait Iterator {
/// Basic usage:
///
/// ```
/// #![feature(iter_intersperse)]
///
/// #[derive(PartialEq, Debug)]
/// struct NotClone(usize);
///
Expand All @@ -599,8 +604,9 @@ 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 @@ -613,7 +619,7 @@ pub trait Iterator {
/// [`Clone`]: crate::clone::Clone
/// [`intersperse`]: Iterator::intersperse
#[inline]
#[stable(feature = "iter_intersperse", since = "1.56.0")]
#[unstable(feature = "iter_intersperse", reason = "recently added", issue = "79524")]
fn intersperse_with<G>(self, separator: G) -> IntersperseWith<Self, G>
where
Self: Sized,
Expand Down
1 change: 1 addition & 0 deletions library/core/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
#![feature(int_log)]
#![feature(iter_advance_by)]
#![feature(iter_partition_in_place)]
#![feature(iter_intersperse)]
#![feature(iter_is_partitioned)]
#![feature(iter_order_by)]
#![feature(const_mut_refs)]
Expand Down
1 change: 1 addition & 0 deletions src/librustdoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#![feature(never_type)]
#![feature(once_cell)]
#![feature(type_ascription)]
#![feature(iter_intersperse)]
#![recursion_limit = "256"]
#![warn(rustc::internal)]

Expand Down