There's already a function to do this:

    fn main() {
        for int::range_step(0, 10, 2) |i| {
            log(error, i);
        }

        for int::range_step(10, 0, -1) |i| {
            log(error, i);
        }
    }


On Fri, Feb 1, 2013 at 7:28 AM, Alexander Stavonin <[email protected]>wrote:

> Thanks, it better than nothing, but… It works only for i++; how can I
> write *i += 2 *or *i--*?
>
> On Feb 1, 2013, at 9:23 PM, Josh Matthews <[email protected]> wrote:
>
> The int/uint::range methods would seem to do the job: for
> uint::range(0, 10) |i| { io::println(fmt!("%u", i)); }
>
> Cheers,
> Josh
>
> On 1 February 2013 12:14, Alexander Stavonin <[email protected]> wrote:
>
> Have we a pretty looks solution for auto incrementation counters during
> loops? I mean something like C/C++ style for loop.I found an example in the
> manual "10.5 For loops" but it looks ugly with counter outside the loop.
>  Is it only way for solving problem?
>
> Thanks.
> _______________________________________________
> Rust-dev mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/rust-dev
>
>
>
> _______________________________________________
> Rust-dev mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/rust-dev
>
>
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to