Skip to content

Commit

Permalink
Add examples for iter::range_step
Browse files Browse the repository at this point in the history
  • Loading branch information
steveklabnik committed Feb 20, 2015
1 parent 522d09d commit 355f355
Showing 1 changed file with 47 additions and 2 deletions.
49 changes: 47 additions & 2 deletions src/libcore/iter.rs
Expand Up @@ -2592,7 +2592,29 @@ pub struct RangeStep<A> {
rev: bool,
}

/// Return an iterator over the range [start, stop) by `step`. It handles overflow by stopping.
/// Return an iterator over the range [start, stop) by `step`.
///
/// It handles overflow by stopping.
///
/// # Examples
///
/// ```
/// use std::iter::range_step;
///
/// for i in range_step(0, 10, 2) {
/// println!("{}", i);
/// }
/// ```
///
/// This prints:
///
/// ```text
/// 0
/// 2
/// 4
/// 6
/// 8
/// ```
#[inline]
#[unstable(feature = "core",
reason = "likely to be replaced by range notation and adapters")]
Expand Down Expand Up @@ -2633,7 +2655,30 @@ pub struct RangeStepInclusive<A> {
done: bool,
}

/// Return an iterator over the range [start, stop] by `step`. It handles overflow by stopping.
/// Return an iterator over the range [start, stop] by `step`.
///
/// It handles overflow by stopping.
///
/// # Examples
///
/// ```
/// use std::iter::range_step_inclusive;
///
/// for i in range_step_inclusive(0, 10, 2) {
/// println!("{}", i);
/// }
/// ```
///
/// This prints:
///
/// ```text
/// 0
/// 2
/// 4
/// 6
/// 8
/// 10
/// ```
#[inline]
#[unstable(feature = "core",
reason = "likely to be replaced by range notation and adapters")]
Expand Down

0 comments on commit 355f355

Please sign in to comment.