Skip to content

Commit

Permalink
Stabilize Iterator::step_by
Browse files Browse the repository at this point in the history
  • Loading branch information
tmccombs committed Jun 3, 2018
1 parent 4ecf12b commit 72e17b8
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 18 deletions.
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

0 comments on commit 72e17b8

Please sign in to comment.