[rust-dev] A question about using uint::range_rev()

Ryan Hyun Choi ryan.choi at samsung.com
Tue Mar 5 20:42:21 PST 2013


Hi all,

I have a quick question about using uint::range_rev().
I'd like to express a for statement that decrements an uint value to 0.
However I cannot use the below statement, because uint::range_rev(i,j) computes
values in the range [i,j).

for uint::range_rev(10,0) |i| {
    // do something
}

Sure I can express the statement using a combination of a while loop and an if statment, 
but is there a compact (or Rust) way of expressing i,..,j? Also, I think type casting to int, use int::range(i,-1), 
and type cast back to uint is only tricking the compiler.

Thanks a lot.

Regards,
Ryan


----
Ryan Hyun Choi
Senior Engineer
Web Platform Lab.
Software R&D Center
Samsung Electronics Co., Ltd
email: ryan.choi at samsung.com


More information about the Rust-dev mailing list