Le 01/02/2013 13:28, Alexander Stavonin a écrit :
Thanks, it better than nothing, but… It works only for i++; how can I write /i += 2 /or /i--/?
The range() function is very simple: https://github.com/mozilla/rust/blob/release-0.5/src/libcore/int-template.rs#L48 #[inline(always)] /// Iterate over the range [`lo`..`hi`) pub fn range(lo: T, hi: T, it: fn(T) -> bool) { let mut i = lo; while i < hi { if !it(i) { break } i += 1 as T; } } It’s quite easy to write your own variant with a "step" parameter: pub pure fn range_step(lo: int, hi: int, step: int, it: fn(int) -> bool) { let mut i = lo; while i < hi { if !it(i) { break } i += step; } } Maybe range_step() could be added to libcore? -- Simon Sapin _______________________________________________ Rust-dev mailing list [email protected] https://mail.mozilla.org/listinfo/rust-dev
