Skip to content

Commit 552c164

Browse files
committed
Parameter/Variable names for for_rev and map extended.
1 parent e4a3b9a commit 552c164

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

doc/tutorial.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1971,18 +1971,18 @@ they apply to. Thus, Rust allows functions and datatypes to have type
19711971
parameters.
19721972
19731973
~~~~
1974-
fn for_rev<T>(v: ~[T], act: fn(T)) {
1975-
let mut i = vec::len(v);
1974+
fn for_rev<T>(vector: ~[T], action fn(T)) {
1975+
let mut i = vec::len(vector);
19761976
while i > 0u {
19771977
i -= 1u;
1978-
act(v[i]);
1978+
action(vector[i]);
19791979
}
19801980
}
19811981
1982-
fn map<T, U>(v: ~[T], f: fn(T) -> U) -> ~[U] {
1983-
let mut acc = ~[];
1984-
for v.each |elt| { vec::push(acc, f(elt)); }
1985-
ret acc;
1982+
fn map<T, U>(vector: ~[T], function :fn(T) -> U) -> ~[U] {
1983+
let mut accumulator = ~[];
1984+
for vector.each |elt| { vec::push(accumulator, function(elt)); }
1985+
ret accumulator;
19861986
}
19871987
~~~~
19881988

0 commit comments

Comments
 (0)