Skip to content

Stabilize step_by for 1.2.0 #25798

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

Closed
wants to merge 1 commit into from
Closed
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
1 change: 0 additions & 1 deletion src/doc/trpl/iterators.md
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,6 @@ has no side effect on the original iterator. Let's try it out with our infinite
iterator from before:

```rust
# #![feature(step_by)]
for i in (1..).step_by(5).take(5) {
println!("{}", i);
}
Expand Down
2 changes: 1 addition & 1 deletion src/libcollections/bit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
//! [sieve]: http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes
//!
//! ```
//! # #![feature(collections, core, step_by)]
//! # #![feature(collections, core)]
//! use std::collections::{BitSet, BitVec};
//! use std::iter;
//!
Expand Down
1 change: 0 additions & 1 deletion src/libcollections/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
#![feature(unicode)]
#![feature(unique)]
#![feature(unsafe_no_drop_flag, filling_drop)]
#![feature(step_by)]
#![feature(str_char)]
#![feature(slice_patterns)]
#![feature(utf8_error)]
Expand Down
1 change: 0 additions & 1 deletion src/libcollectionstest/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#![feature(unboxed_closures)]
#![feature(unicode)]
#![feature(into_cow)]
#![feature(step_by)]
#![cfg_attr(test, feature(str_char))]
#![cfg_attr(test, feature(vec_deque_retain))]

Expand Down
17 changes: 12 additions & 5 deletions src/libcore/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -513,13 +513,15 @@ pub trait Iterator {
/// # Examples
///
/// ```
/// # #![feature(core)]
///
/// let a = [1, 4, 2, 3, 8, 9, 6];
/// let sum: i32 = a.iter()
/// .map(|x| *x)
/// .inspect(|&x| println!("filtering {}", x))
/// .filter(|&x| x % 2 == 0)
/// .inspect(|&x| println!("{} made it through", x))
/// .fold(0, |sum, i| sum + i);
/// .sum();
/// println!("{}", sum);
/// ```
#[inline]
Expand Down Expand Up @@ -569,6 +571,7 @@ pub trait Iterator {
/// do not.
///
/// ```
/// # #![feature(core)]
/// let vec = vec![1, 2, 3, 4];
/// let (even, odd): (Vec<_>, Vec<_>) = vec.into_iter().partition(|&n| n % 2 == 0);
/// assert_eq!(even, [2, 4]);
Expand Down Expand Up @@ -893,6 +896,7 @@ pub trait Iterator {
///
/// ```
/// # #![feature(core)]
///
/// let a = [-3_i32, 0, 1, 5, -10];
/// assert_eq!(*a.iter().max_by(|x| x.abs()).unwrap(), -10);
/// ```
Expand Down Expand Up @@ -921,6 +925,7 @@ pub trait Iterator {
///
/// ```
/// # #![feature(core)]
///
/// let a = [-3_i32, 0, 1, 5, -10];
/// assert_eq!(*a.iter().min_by(|x| x.abs()).unwrap(), 0);
/// ```
Expand Down Expand Up @@ -965,6 +970,7 @@ pub trait Iterator {
/// # Examples
///
/// ```
/// # #![feature(core)]
/// let a = [(1, 2), (3, 4)];
/// let (left, right): (Vec<_>, Vec<_>) = a.iter().cloned().unzip();
/// assert_eq!(left, [1, 3]);
Expand Down Expand Up @@ -1058,6 +1064,7 @@ pub trait Iterator {
///
/// ```
/// # #![feature(core)]
///
/// let a = [1, 2, 3, 4, 5];
/// let it = a.iter();
/// assert_eq!(it.sum::<i32>(), 15);
Expand All @@ -1076,6 +1083,7 @@ pub trait Iterator {
///
/// ```
/// # #![feature(core)]
///
/// fn factorial(n: u32) -> u32 {
/// (1..).take_while(|&i| i <= n).product()
/// }
Expand Down Expand Up @@ -2683,7 +2691,7 @@ step_impl_no_between!(u64 i64);
/// parameter is the type being iterated over, while `R` is the range
/// type (usually one of `std::ops::{Range, RangeFrom}`.
#[derive(Clone)]
#[unstable(feature = "step_by", reason = "recent addition")]
#[stable(feature = "step_by", since = "1.2.0")]
pub struct StepBy<A, R> {
step_by: A,
range: R,
Expand All @@ -2702,7 +2710,7 @@ impl<A: Step> RangeFrom<A> {
/// ```
///
/// This prints all even `u8` values.
#[unstable(feature = "step_by", reason = "recent addition")]
#[stable(feature = "step_by", since = "1.2.0")]
pub fn step_by(self, by: A) -> StepBy<A, Self> {
StepBy {
step_by: by,
Expand All @@ -2721,7 +2729,6 @@ impl<A: Step> ops::Range<A> {
/// # Examples
///
/// ```
/// # #![feature(step_by)]
/// for i in (0..10).step_by(2) {
/// println!("{}", i);
/// }
Expand All @@ -2736,7 +2743,7 @@ impl<A: Step> ops::Range<A> {
/// 6
/// 8
/// ```
#[unstable(feature = "step_by", reason = "recent addition")]
#[stable(feature = "step_by", since = "1.2.0")]
pub fn step_by(self, by: A) -> StepBy<A, Self> {
StepBy {
step_by: by,
Expand Down
1 change: 0 additions & 1 deletion src/libcoretest/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#![feature(libc)]
#![feature(hash)]
#![feature(unique)]
#![feature(step_by)]
#![feature(slice_patterns)]
#![feature(float_from_str_radix)]
#![feature(cell_extras)]
Expand Down
1 change: 0 additions & 1 deletion src/librand/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#![feature(core)]
#![feature(no_std)]
#![feature(staged_api)]
#![feature(step_by)]

#![cfg_attr(test, feature(test, rand, rustc_private))]

Expand Down
1 change: 0 additions & 1 deletion src/librustc_back/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
#![feature(staged_api)]
#![feature(rand)]
#![feature(path_ext)]
#![feature(step_by)]
#![feature(libc)]
#![feature(fs_canonicalize)]
#![cfg_attr(test, feature(test, rand))]
Expand Down
2 changes: 1 addition & 1 deletion src/test/bench/shootout-binarytrees.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
// OF THE POSSIBILITY OF SUCH DAMAGE.

#![feature(rustc_private, core, step_by)]
#![feature(rustc_private, core)]

extern crate arena;

Expand Down
2 changes: 0 additions & 2 deletions src/test/bench/shootout-fannkuch-redux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
// OF THE POSSIBILITY OF SUCH DAMAGE.

#![feature(step_by)]

use std::{cmp, mem};
use std::thread;

Expand Down