Skip to content

Commit 76a3006

Browse files
committed
Stabilize step_by for 1.2.0
step_by is generally useful (it was used in multiple places in the standard library). When it landed in mid-March, it was marked unstable because it was a "recent addition" to the API. It's been two months, and there seems to be no controversy about its inclusion in Rust. Therefore, I propose that we stabilize step_by.
1 parent 776f87e commit 76a3006

File tree

10 files changed

+14
-15
lines changed

10 files changed

+14
-15
lines changed

src/doc/trpl/iterators.md

-1
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,6 @@ has no side effect on the original iterator. Let's try it out with our infinite
285285
iterator from before:
286286

287287
```rust
288-
# #![feature(step_by)]
289288
for i in (1..).step_by(5).take(5) {
290289
println!("{}", i);
291290
}

src/libcollections/bit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
//! [sieve]: http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes
3939
//!
4040
//! ```
41-
//! # #![feature(collections, core, step_by)]
41+
//! # #![feature(collections, core)]
4242
//! use std::collections::{BitSet, BitVec};
4343
//! use std::iter;
4444
//!

src/libcollections/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
#![feature(unicode)]
3636
#![feature(unique)]
3737
#![feature(unsafe_no_drop_flag, filling_drop)]
38-
#![feature(step_by)]
3938
#![feature(str_char)]
4039
#![feature(slice_patterns)]
4140
#![feature(utf8_error)]

src/libcollectionstest/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#![feature(unboxed_closures)]
2323
#![feature(unicode)]
2424
#![feature(into_cow)]
25-
#![feature(step_by)]
2625
#![cfg_attr(test, feature(str_char))]
2726
#![cfg_attr(test, feature(vec_deque_retain))]
2827

src/libcore/iter.rs

+12-5
Original file line numberDiff line numberDiff line change
@@ -513,13 +513,15 @@ pub trait Iterator {
513513
/// # Examples
514514
///
515515
/// ```
516+
/// # #![feature(core)]
517+
///
516518
/// let a = [1, 4, 2, 3, 8, 9, 6];
517519
/// let sum: i32 = a.iter()
518520
/// .map(|x| *x)
519521
/// .inspect(|&x| println!("filtering {}", x))
520522
/// .filter(|&x| x % 2 == 0)
521523
/// .inspect(|&x| println!("{} made it through", x))
522-
/// .fold(0, |sum, i| sum + i);
524+
/// .sum();
523525
/// println!("{}", sum);
524526
/// ```
525527
#[inline]
@@ -569,6 +571,7 @@ pub trait Iterator {
569571
/// do not.
570572
///
571573
/// ```
574+
/// # #![feature(core)]
572575
/// let vec = vec![1, 2, 3, 4];
573576
/// let (even, odd): (Vec<_>, Vec<_>) = vec.into_iter().partition(|&n| n % 2 == 0);
574577
/// assert_eq!(even, [2, 4]);
@@ -893,6 +896,7 @@ pub trait Iterator {
893896
///
894897
/// ```
895898
/// # #![feature(core)]
899+
///
896900
/// let a = [-3_i32, 0, 1, 5, -10];
897901
/// assert_eq!(*a.iter().max_by(|x| x.abs()).unwrap(), -10);
898902
/// ```
@@ -921,6 +925,7 @@ pub trait Iterator {
921925
///
922926
/// ```
923927
/// # #![feature(core)]
928+
///
924929
/// let a = [-3_i32, 0, 1, 5, -10];
925930
/// assert_eq!(*a.iter().min_by(|x| x.abs()).unwrap(), 0);
926931
/// ```
@@ -965,6 +970,7 @@ pub trait Iterator {
965970
/// # Examples
966971
///
967972
/// ```
973+
/// # #![feature(core)]
968974
/// let a = [(1, 2), (3, 4)];
969975
/// let (left, right): (Vec<_>, Vec<_>) = a.iter().cloned().unzip();
970976
/// assert_eq!(left, [1, 3]);
@@ -1058,6 +1064,7 @@ pub trait Iterator {
10581064
///
10591065
/// ```
10601066
/// # #![feature(core)]
1067+
///
10611068
/// let a = [1, 2, 3, 4, 5];
10621069
/// let it = a.iter();
10631070
/// assert_eq!(it.sum::<i32>(), 15);
@@ -1076,6 +1083,7 @@ pub trait Iterator {
10761083
///
10771084
/// ```
10781085
/// # #![feature(core)]
1086+
///
10791087
/// fn factorial(n: u32) -> u32 {
10801088
/// (1..).take_while(|&i| i <= n).product()
10811089
/// }
@@ -2683,7 +2691,7 @@ step_impl_no_between!(u64 i64);
26832691
/// parameter is the type being iterated over, while `R` is the range
26842692
/// type (usually one of `std::ops::{Range, RangeFrom}`.
26852693
#[derive(Clone)]
2686-
#[unstable(feature = "step_by", reason = "recent addition")]
2694+
#[stable(feature = "step_by", since = "1.2.0")]
26872695
pub struct StepBy<A, R> {
26882696
step_by: A,
26892697
range: R,
@@ -2702,7 +2710,7 @@ impl<A: Step> RangeFrom<A> {
27022710
/// ```
27032711
///
27042712
/// This prints all even `u8` values.
2705-
#[unstable(feature = "step_by", reason = "recent addition")]
2713+
#[stable(feature = "step_by", since = "1.2.0")]
27062714
pub fn step_by(self, by: A) -> StepBy<A, Self> {
27072715
StepBy {
27082716
step_by: by,
@@ -2721,7 +2729,6 @@ impl<A: Step> ops::Range<A> {
27212729
/// # Examples
27222730
///
27232731
/// ```
2724-
/// # #![feature(step_by)]
27252732
/// for i in (0..10).step_by(2) {
27262733
/// println!("{}", i);
27272734
/// }
@@ -2736,7 +2743,7 @@ impl<A: Step> ops::Range<A> {
27362743
/// 6
27372744
/// 8
27382745
/// ```
2739-
#[unstable(feature = "step_by", reason = "recent addition")]
2746+
#[stable(feature = "step_by", since = "1.2.0")]
27402747
pub fn step_by(self, by: A) -> StepBy<A, Self> {
27412748
StepBy {
27422749
step_by: by,

src/libcoretest/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#![feature(libc)]
2323
#![feature(hash)]
2424
#![feature(unique)]
25-
#![feature(step_by)]
2625
#![feature(slice_patterns)]
2726
#![feature(float_from_str_radix)]
2827
#![feature(cell_extras)]

src/librand/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
#![feature(core)]
3232
#![feature(no_std)]
3333
#![feature(staged_api)]
34-
#![feature(step_by)]
3534

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

src/librustc_back/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
#![feature(staged_api)]
4040
#![feature(rand)]
4141
#![feature(path_ext)]
42-
#![feature(step_by)]
4342
#![feature(libc)]
4443
#![feature(fs_canonicalize)]
4544
#![cfg_attr(test, feature(test, rand))]

src/test/bench/shootout-binarytrees.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
3939
// OF THE POSSIBILITY OF SUCH DAMAGE.
4040

41-
#![feature(rustc_private, core, step_by)]
41+
#![feature(rustc_private, core)]
4242

4343
extern crate arena;
4444

src/test/bench/shootout-fannkuch-redux.rs

-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@
3838
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
3939
// OF THE POSSIBILITY OF SUCH DAMAGE.
4040

41-
#![feature(step_by)]
42-
4341
use std::{cmp, mem};
4442
use std::thread;
4543

0 commit comments

Comments
 (0)