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

Stabilize Iterator::step_by #51320

Merged
merged 1 commit into from
Jun 10, 2018
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
Stabilize Iterator::step_by
Fixes #27741
  • Loading branch information
tmccombs committed Jun 3, 2018
commit 72e17b81fa88894e3fe04f221166f5a48e753e94
1 change: 0 additions & 1 deletion src/liballoc/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 15,6 @@
#![feature(const_fn)]
#![feature(drain_filter)]
#![feature(exact_size_is_empty)]
#![feature(iterator_step_by)]
#![feature(pattern)]
#![feature(rand)]
#![feature(slice_sort_by_cached_key)]
Expand Down
5 changes: 1 addition & 4 deletions src/libcore/iter/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 283,6 @@ pub trait Iterator {
/// Basic usage:
///
/// ```
/// #![feature(iterator_step_by)]
/// let a = [0, 1, 2, 3, 4, 5];
/// let mut iter = a.into_iter().step_by(2);
///
Expand All @@ -293,9 292,7 @@ pub trait Iterator {
/// assert_eq!(iter.next(), None);
/// ```
#[inline]
#[unstable(feature = "iterator_step_by",
reason = "unstable replacement of Range::step_by",
issue = "27741")]
#[stable(feature = "iterator_step_by", since = "1.28.0")]
fn step_by(self, step: usize) -> StepBy<Self> where Self: Sized {
assert!(step != 0);
StepBy{iter: self, step: step - 1, first_take: true}
Expand Down
12 changes: 3 additions & 9 deletions src/libcore/iter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -673,19 673,15 @@ impl<I> FusedIterator for Cycle<I> where I: Clone Iterator {}
/// [`step_by`]: trait.Iterator.html#method.step_by
/// [`Iterator`]: trait.Iterator.html
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
#[unstable(feature = "iterator_step_by",
reason = "unstable replacement of Range::step_by",
issue = "27741")]
#[stable(feature = "iterator_step_by", since = "1.28.0")]
#[derive(Clone, Debug)]
pub struct StepBy<I> {
iter: I,
step: usize,
first_take: bool,
}

#[unstable(feature = "iterator_step_by",
reason = "unstable replacement of Range::step_by",
issue = "27741")]
#[stable(feature = "iterator_step_by", since = "1.28.0")]
impl<I> Iterator for StepBy<I> where I: Iterator {
type Item = I::Item;

Expand Down Expand Up @@ -757,9 753,7 @@ impl<I> Iterator for StepBy<I> where I: Iterator {
}

// StepBy can only make the iterator shorter, so the len will still fit.
#[unstable(feature = "iterator_step_by",
reason = "unstable replacement of Range::step_by",
issue = "27741")]
#[stable(feature = "iterator_step_by", since = "1.28.0")]
impl<I> ExactSizeIterator for StepBy<I> where I: ExactSizeIterator {}

/// An iterator that strings two iterators together.
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_step_by)]
#![feature(iterator_flatten)]
#![feature(iterator_repeat_with)]
#![feature(pattern)]
Expand Down
2 changes: 0 additions & 2 deletions src/test/run-pass/range_inclusive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 10,6 @@

// Test inclusive range syntax.

#![feature(iterator_step_by)]

use std::ops::{RangeInclusive, RangeToInclusive};

fn foo() -> isize { 42 }
Expand Down
1 change: 0 additions & 1 deletion src/test/run-pass/sync-send-iterators-in-libcore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 14,6 @@
#![feature(iter_empty)]
#![feature(iter_once)]
#![feature(iter_unfold)]
#![feature(iterator_step_by)]
#![feature(str_escape)]

use std::iter::{empty, once, repeat};
Expand Down