mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-08 04:56:58 +00:00
auto merge of #6841 : steveklabnik/rust/range_docs, r=thestinger
This commit is contained in:
commit
f8cef24b5e
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user