Skip to content

Commit

Permalink
Add example for uint::range_step.
Browse files Browse the repository at this point in the history
  • Loading branch information
steveklabnik committed May 30, 2013
1 parent 784a849 commit 220e1a6
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/libstd/num/uint_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,18 @@ pub fn ge(x: $T, y: $T) -> bool { x >= y }
pub fn gt(x: $T, y: $T) -> bool { x > y }

#[inline(always)]
///
/// Iterate over the range [`start`,`start`+`step`..`stop`)
///
/**
* Iterate through a range with a given step value.
*
* # Examples
* ~~~ {.rust}
* let nums = [1,2,3,4,5,6,7];
*
* for uint::range_step(0, nums.len() - 1, 2) |i| {
* println(fmt!("%d & %d", nums[i], nums[i+1]));
* }
* ~~~
*/
pub fn range_step(start: $T, stop: $T, step: $T_SIGNED, it: &fn($T) -> bool) -> bool {
let mut i = start;
if step == 0 {
Expand Down

5 comments on commit 220e1a6

@bors
Copy link
Contributor

@bors bors commented on 220e1a6 May 31, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from thestinger
at steveklabnik@220e1a6

@bors
Copy link
Contributor

@bors bors commented on 220e1a6 May 31, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging steveklabnik/rust/range_docs = 220e1a6 into auto

@bors
Copy link
Contributor

@bors bors commented on 220e1a6 May 31, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

steveklabnik/rust/range_docs = 220e1a6 merged ok, testing candidate = f8cef24

@bors
Copy link
Contributor

@bors bors commented on 220e1a6 May 31, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on 220e1a6 May 31, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding incoming to auto = f8cef24

Please sign in to comment.