File tree Expand file tree Collapse file tree 1 file changed +47
-2
lines changed Expand file tree Collapse file tree 1 file changed +47
-2
lines changed Original file line number Diff line number Diff line change @@ -2592,7 +2592,29 @@ pub struct RangeStep<A> {
2592
2592
rev : bool ,
2593
2593
}
2594
2594
2595
- /// Return an iterator over the range [start, stop) by `step`. It handles overflow by stopping.
2595
+ /// Return an iterator over the range [start, stop) by `step`.
2596
+ ///
2597
+ /// It handles overflow by stopping.
2598
+ ///
2599
+ /// # Examples
2600
+ ///
2601
+ /// ```
2602
+ /// use std::iter::range_step;
2603
+ ///
2604
+ /// for i in range_step(0, 10, 2) {
2605
+ /// println!("{}", i);
2606
+ /// }
2607
+ /// ```
2608
+ ///
2609
+ /// This prints:
2610
+ ///
2611
+ /// ```text
2612
+ /// 0
2613
+ /// 2
2614
+ /// 4
2615
+ /// 6
2616
+ /// 8
2617
+ /// ```
2596
2618
#[ inline]
2597
2619
#[ unstable( feature = "core" ,
2598
2620
reason = "likely to be replaced by range notation and adapters" ) ]
@@ -2633,7 +2655,30 @@ pub struct RangeStepInclusive<A> {
2633
2655
done : bool ,
2634
2656
}
2635
2657
2636
- /// Return an iterator over the range [start, stop] by `step`. It handles overflow by stopping.
2658
+ /// Return an iterator over the range [start, stop] by `step`.
2659
+ ///
2660
+ /// It handles overflow by stopping.
2661
+ ///
2662
+ /// # Examples
2663
+ ///
2664
+ /// ```
2665
+ /// use std::iter::range_step_inclusive;
2666
+ ///
2667
+ /// for i in range_step_inclusive(0, 10, 2) {
2668
+ /// println!("{}", i);
2669
+ /// }
2670
+ /// ```
2671
+ ///
2672
+ /// This prints:
2673
+ ///
2674
+ /// ```text
2675
+ /// 0
2676
+ /// 2
2677
+ /// 4
2678
+ /// 6
2679
+ /// 8
2680
+ /// 10
2681
+ /// ```
2637
2682
#[ inline]
2638
2683
#[ unstable( feature = "core" ,
2639
2684
reason = "likely to be replaced by range notation and adapters" ) ]
You can’t perform that action at this time.
0 commit comments