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

Niko Matsakis niko at alum.mit.edu
Wed Mar 6 05:45:45 PST 2013


Yeah, I'm inclined to agree.


Niko

> Benjamin Striegel <mailto:ben.striegel at gmail.com>
> March 6, 2013 12:55 AM
> Hm, well that's unfortunate...
>
> I think that range_rev might just need to be rewritten to get the 
> values in (i, j] rather than [i, j).
>
>
>
> _______________________________________________
> Rust-dev mailing list
> Rust-dev at mozilla.org
> https://mail.mozilla.org/listinfo/rust-dev
> Ryan Hyun Choi <mailto:ryan.choi at samsung.com>
> March 5, 2013 11:42 PM
> 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
> _______________________________________________
> Rust-dev mailing list
> Rust-dev at mozilla.org
> https://mail.mozilla.org/listinfo/rust-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/rust-dev/attachments/20130306/3372f206/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: postbox-contact.jpg
Type: image/jpeg
Size: 1106 bytes
Desc: not available
URL: <http://mail.mozilla.org/pipermail/rust-dev/attachments/20130306/3372f206/attachment.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: compose-unknown-contact.jpg
Type: image/jpeg
Size: 770 bytes
Desc: not available
URL: <http://mail.mozilla.org/pipermail/rust-dev/attachments/20130306/3372f206/attachment-0001.jpg>


More information about the Rust-dev mailing list