Skip to content

Commit

Permalink
Auto merge of #51511 - Centril:feature/stabilize_iterator_flatten, r=…
Browse files Browse the repository at this point in the history
…<try>

Stabilize Iterator::flatten in 1.29, fixes #48213.

This PR stabilizes [`Iterator::flatten`](https://doc.rust-lang.org/nightly/std/iter/trait.Iterator.html#method.flatten) in *version 1.29* (1.28 goes to beta in 10 days, I don't think there's enough time to land it in that time, but let's see...).

Tracking issue is:  #48213.

cc @bluss re. itertools.
r? @SimonSapin
ping @pietroalbini -- let's do a crater run when this passes CI :)
  • Loading branch information
bors committed Jun 11, 2018
2 parents 0b7c9e7 + 85796dd commit b534f2e
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 15 deletions.
8 changes: 1 addition & 7 deletions src/libcore/iter/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1036,8 +1036,6 @@ pub trait Iterator {
/// Basic usage:
///
/// ```
/// #![feature(iterator_flatten)]
///
/// let data = vec![vec![1, 2, 3, 4], vec![5, 6]];
/// let flattened = data.into_iter().flatten().collect::<Vec<u8>>();
/// assert_eq!(flattened, &[1, 2, 3, 4, 5, 6]);
Expand All @@ -1046,8 +1044,6 @@ pub trait Iterator {
/// Mapping and then flattening:
///
/// ```
/// #![feature(iterator_flatten)]
///
/// let words = ["alpha", "beta", "gamma"];
///
/// // chars() returns an iterator
Expand All @@ -1074,8 +1070,6 @@ pub trait Iterator {
/// Flattening once only removes one level of nesting:
///
/// ```
/// #![feature(iterator_flatten)]
///
/// let d3 = [[[1, 2], [3, 4]], [[5, 6], [7, 8]]];
///
/// let d2 = d3.iter().flatten().collect::<Vec<_>>();
Expand All @@ -1093,7 +1087,7 @@ pub trait Iterator {
///
/// [`flat_map()`]: #method.flat_map
#[inline]
#[unstable(feature = "iterator_flatten", issue = "48213")]
#[stable(feature = "iterator_flatten", since = "1.29")]
fn flatten(self) -> Flatten<Self>
where Self: Sized, Self::Item: IntoIterator {
Flatten { inner: flatten_compat(self) }
Expand Down
12 changes: 6 additions & 6 deletions src/libcore/iter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2524,13 +2524,13 @@ impl<I, U, F> FusedIterator for FlatMap<I, U, F>
/// [`flatten`]: trait.Iterator.html#method.flatten
/// [`Iterator`]: trait.Iterator.html
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
#[unstable(feature = "iterator_flatten", issue = "48213")]
#[stable(feature = "iterator_flatten", since = "1.29")]
pub struct Flatten<I: Iterator>
where I::Item: IntoIterator {
inner: FlattenCompat<I, <I::Item as IntoIterator>::IntoIter>,
}

#[unstable(feature = "iterator_flatten", issue = "48213")]
#[stable(feature = "iterator_flatten", since = "1.29")]
impl<I, U> fmt::Debug for Flatten<I>
where I: Iterator + fmt::Debug, U: Iterator + fmt::Debug,
I::Item: IntoIterator<IntoIter = U, Item = U::Item>,
Expand All @@ -2540,15 +2540,15 @@ impl<I, U> fmt::Debug for Flatten<I>
}
}

#[unstable(feature = "iterator_flatten", issue = "48213")]
#[stable(feature = "iterator_flatten", since = "1.29")]
impl<I, U> Clone for Flatten<I>
where I: Iterator + Clone, U: Iterator + Clone,
I::Item: IntoIterator<IntoIter = U, Item = U::Item>,
{
fn clone(&self) -> Self { Flatten { inner: self.inner.clone() } }
}

#[unstable(feature = "iterator_flatten", issue = "48213")]
#[stable(feature = "iterator_flatten", since = "1.29")]
impl<I, U> Iterator for Flatten<I>
where I: Iterator, U: Iterator,
I::Item: IntoIterator<IntoIter = U, Item = U::Item>
Expand Down Expand Up @@ -2576,7 +2576,7 @@ impl<I, U> Iterator for Flatten<I>
}
}

#[unstable(feature = "iterator_flatten", issue = "48213")]
#[stable(feature = "iterator_flatten", since = "1.29")]
impl<I, U> DoubleEndedIterator for Flatten<I>
where I: DoubleEndedIterator, U: DoubleEndedIterator,
I::Item: IntoIterator<IntoIter = U, Item = U::Item>
Expand All @@ -2599,7 +2599,7 @@ impl<I, U> DoubleEndedIterator for Flatten<I>
}
}

#[unstable(feature = "iterator_flatten", issue = "48213")]
#[stable(feature = "iterator_flatten", since = "1.29")]
impl<I, U> FusedIterator for Flatten<I>
where I: FusedIterator, U: Iterator,
I::Item: IntoIterator<IntoIter = U, Item = U::Item> {}
Expand Down
1 change: 0 additions & 1 deletion src/libcore/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@
#![feature(extern_types)]
#![feature(fundamental)]
#![feature(intrinsics)]
#![feature(iterator_flatten)]
#![feature(lang_items)]
#![feature(link_llvm_intrinsics)]
#![feature(never_type)]
Expand Down
1 change: 0 additions & 1 deletion src/libcore/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#![feature(flt2dec)]
#![feature(fmt_internals)]
#![feature(hashmap_internals)]
#![feature(iterator_flatten)]
#![feature(pattern)]
#![feature(range_is_empty)]
#![feature(raw)]
Expand Down

0 comments on commit b534f2e

Please sign in to comment.