5 ms·
Re: your second example, once upon a time you could write something very similar in Rust: do 5.times { // ... } Where do was just sugar for calling fu
by pitterpatter 7y ago
Re: your second example, once upon a time you could write something very similar in Rust:
do 5.times {
// ...
}
Where do was just sugar for calling functions that took a closure as the last argument:
fn foo(a: A, ..., z: Z, cl: ||) { ... }
foo(a, ..., z, || {
...
})
do foo(a, ..., z) {
...
}
- pitterpatter 7y agoIn fact, before the current for ... in ... syntax, this is how foreach looping used to be done: do some_array.each |item| { ... }