Ben Striegel
d162fa26ba
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".
This is a compiler and suite of associated libraries and documentation for the Rust programming language. See LICENSE.txt for terms of copyright and redistribution. See http://www.rust-lang.org for more information.
Description
Languages
Rust
96.2%
RenderScript
0.7%
JavaScript
0.6%
Shell
0.6%
Fluent
0.4%
Other
1.3%