about summary refs log tree commit diff
path: root/src/rt/rust_task.cpp
diff options
context:
space:
mode:
authorBen Striegel <ben.striegel@gmail.com>2012-07-05 22:12:26 -0400
committerBrian Anderson <banderson@mozilla.com>2012-07-05 19:44:20 -0700
commitd162fa26ba014dcb20e41e31e9c7f969301f532c (patch)
tree970ca68b993a8cdb46e1633920d245dc04ba5c25 /src/rt/rust_task.cpp
parenta8112f3b348645f6f487aaa1ae0918b719045f1b (diff)
downloadrust-d162fa26ba014dcb20e41e31e9c7f969301f532c.tar.gz
rust-d162fa26ba014dcb20e41e31e9c7f969301f532c.zip
A new `times` method on numeric types
This method is intended to elegantly subsume two common iteration functions.
The first is `iter::range`, which is used identically to the method introduced
in this commit, but currently works only on uints. The second is a common case
of `{int, i8, uint, etc.}::range`, in the case where the inductive variable is
ignored. Compare the usage of the three:
```
for iter::range(100u) {
    // do whatever
}

for int::range(0, 100) |_i| {
    // do whatever
}

for 100.times {
    // do whatever
}
```
I feel that the latter reads much more nicely than the first two approaches,
and unlike the first two the new method allows the user to ignore the specific
type of the number (ineed, if we're throwing away the inductive variable, who
cares what type it is?). A minor benefit is that this new method will be
somewhat familiar to users of Ruby, from which we borrow the name "times".
Diffstat (limited to 'src/rt/rust_task.cpp')
0 files changed, 0 insertions, 0 deletions