@@ -513,13 +513,15 @@ pub trait Iterator {
513
513
/// # Examples
514
514
///
515
515
/// ```
516
+ /// # #![feature(core)]
517
+ ///
516
518
/// let a = [1, 4, 2, 3, 8, 9, 6];
517
519
/// let sum: i32 = a.iter()
518
520
/// .map(|x| *x)
519
521
/// .inspect(|&x| println!("filtering {}", x))
520
522
/// .filter(|&x| x % 2 == 0)
521
523
/// .inspect(|&x| println!("{} made it through", x))
522
- /// .fold(0, | sum, i| sum + i );
524
+ /// .sum( );
523
525
/// println!("{}", sum);
524
526
/// ```
525
527
#[ inline]
@@ -569,6 +571,7 @@ pub trait Iterator {
569
571
/// do not.
570
572
///
571
573
/// ```
574
+ /// # #![feature(core)]
572
575
/// let vec = vec![1, 2, 3, 4];
573
576
/// let (even, odd): (Vec<_>, Vec<_>) = vec.into_iter().partition(|&n| n % 2 == 0);
574
577
/// assert_eq!(even, [2, 4]);
@@ -893,6 +896,7 @@ pub trait Iterator {
893
896
///
894
897
/// ```
895
898
/// # #![feature(core)]
899
+ ///
896
900
/// let a = [-3_i32, 0, 1, 5, -10];
897
901
/// assert_eq!(*a.iter().max_by(|x| x.abs()).unwrap(), -10);
898
902
/// ```
@@ -921,6 +925,7 @@ pub trait Iterator {
921
925
///
922
926
/// ```
923
927
/// # #![feature(core)]
928
+ ///
924
929
/// let a = [-3_i32, 0, 1, 5, -10];
925
930
/// assert_eq!(*a.iter().min_by(|x| x.abs()).unwrap(), 0);
926
931
/// ```
@@ -965,6 +970,7 @@ pub trait Iterator {
965
970
/// # Examples
966
971
///
967
972
/// ```
973
+ /// # #![feature(core)]
968
974
/// let a = [(1, 2), (3, 4)];
969
975
/// let (left, right): (Vec<_>, Vec<_>) = a.iter().cloned().unzip();
970
976
/// assert_eq!(left, [1, 3]);
@@ -1058,6 +1064,7 @@ pub trait Iterator {
1058
1064
///
1059
1065
/// ```
1060
1066
/// # #![feature(core)]
1067
+ ///
1061
1068
/// let a = [1, 2, 3, 4, 5];
1062
1069
/// let it = a.iter();
1063
1070
/// assert_eq!(it.sum::<i32>(), 15);
@@ -1076,6 +1083,7 @@ pub trait Iterator {
1076
1083
///
1077
1084
/// ```
1078
1085
/// # #![feature(core)]
1086
+ ///
1079
1087
/// fn factorial(n: u32) -> u32 {
1080
1088
/// (1..).take_while(|&i| i <= n).product()
1081
1089
/// }
@@ -2683,7 +2691,7 @@ step_impl_no_between!(u64 i64);
2683
2691
/// parameter is the type being iterated over, while `R` is the range
2684
2692
/// type (usually one of `std::ops::{Range, RangeFrom}`.
2685
2693
#[ derive( Clone ) ]
2686
- #[ unstable ( feature = "step_by" , reason = "recent addition " ) ]
2694
+ #[ stable ( feature = "step_by" , since = "1.2.0 " ) ]
2687
2695
pub struct StepBy < A , R > {
2688
2696
step_by : A ,
2689
2697
range : R ,
@@ -2702,7 +2710,7 @@ impl<A: Step> RangeFrom<A> {
2702
2710
/// ```
2703
2711
///
2704
2712
/// This prints all even `u8` values.
2705
- #[ unstable ( feature = "step_by" , reason = "recent addition " ) ]
2713
+ #[ stable ( feature = "step_by" , since = "1.2.0 " ) ]
2706
2714
pub fn step_by ( self , by : A ) -> StepBy < A , Self > {
2707
2715
StepBy {
2708
2716
step_by : by,
@@ -2721,7 +2729,6 @@ impl<A: Step> ops::Range<A> {
2721
2729
/// # Examples
2722
2730
///
2723
2731
/// ```
2724
- /// # #![feature(step_by)]
2725
2732
/// for i in (0..10).step_by(2) {
2726
2733
/// println!("{}", i);
2727
2734
/// }
@@ -2736,7 +2743,7 @@ impl<A: Step> ops::Range<A> {
2736
2743
/// 6
2737
2744
/// 8
2738
2745
/// ```
2739
- #[ unstable ( feature = "step_by" , reason = "recent addition " ) ]
2746
+ #[ stable ( feature = "step_by" , since = "1.2.0 " ) ]
2740
2747
pub fn step_by ( self , by : A ) -> StepBy < A , Self > {
2741
2748
StepBy {
2742
2749
step_by : by,
0 commit comments