@@ -1361,7 +1361,7 @@ the enclosing scope.
13611361
13621362~~~~
13631363# use println = core::io::println;
1364- fn call_closure_with_ten(b: fn(int)) { b(10); }
1364+ fn call_closure_with_ten(b: & fn(int)) { b(10); }
13651365
13661366let captured_var = 20;
13671367let closure = |arg| println(fmt!("captured_var=%d, arg=%d", captured_var, arg));
@@ -1447,7 +1447,7 @@ should almost always declare the type of that argument as `fn()`. That way,
14471447callers may pass any kind of closure.
14481448
14491449~~~~
1450- fn call_twice(f: fn()) { f(); f(); }
1450+ fn call_twice(f: & fn()) { f(); f(); }
14511451let closure = || { "I'm a closure, and it doesn't matter what type I am"; };
14521452fn function() { "I'm a normal function"; }
14531453call_twice(closure);
@@ -1467,7 +1467,7 @@ Consider this function that iterates over a vector of
14671467integers, passing in a pointer to each integer in the vector:
14681468
14691469~~~~
1470- fn each(v: &[int], op: fn(v: &int)) {
1470+ fn each(v: &[int], op: & fn(v: &int)) {
14711471 let mut n = 0;
14721472 while n < v.len() {
14731473 op(&v[n]);
@@ -1488,7 +1488,7 @@ argument, we can write it in a way that has a pleasant, block-like
14881488structure.
14891489
14901490~~~~
1491- # fn each(v: &[int], op: fn(v: &int)) { }
1491+ # fn each(v: &[int], op: & fn(v: &int)) { }
14921492# fn do_some_work(i: &int) { }
14931493each([1, 2, 3], |n| {
14941494 do_some_work(n);
@@ -1499,7 +1499,7 @@ This is such a useful pattern that Rust has a special form of function
14991499call that can be written more like a built-in control structure:
15001500
15011501~~~~
1502- # fn each(v: &[int], op: fn(v: &int)) { }
1502+ # fn each(v: &[int], op: & fn(v: &int)) { }
15031503# fn do_some_work(i: &int) { }
15041504do each([1, 2, 3]) |n| {
15051505 do_some_work(n);
@@ -1546,7 +1546,7 @@ Consider again our `each` function, this time improved to
15461546break early when the iteratee returns ` false ` :
15471547
15481548~~~~
1549- fn each(v: &[int], op: fn(v: &int) -> bool) {
1549+ fn each(v: &[int], op: & fn(v: &int) -> bool) {
15501550 let mut n = 0;
15511551 while n < v.len() {
15521552 if !op(&v[n]) {
@@ -1770,7 +1770,7 @@ vector consisting of the result of applying `function` to each element
17701770of ` vector ` :
17711771
17721772~~~~
1773- fn map<T, U>(vector: &[T], function: fn(v: &T) -> U) -> ~[U] {
1773+ fn map<T, U>(vector: &[T], function: & fn(v: &T) -> U) -> ~[U] {
17741774 let mut accumulator = ~[];
17751775 for vec::each(vector) |element| {
17761776 accumulator.push(function(element));
@@ -1969,12 +1969,12 @@ types might look like the following:
19691969~~~~
19701970trait Seq<T> {
19711971 fn len(&self) -> uint;
1972- fn iter(&self, b: fn(v: &T));
1972+ fn iter(&self, b: & fn(v: &T));
19731973}
19741974
19751975impl<T> Seq<T> for ~[T] {
19761976 fn len(&self) -> uint { vec::len(*self) }
1977- fn iter(&self, b: fn(v: &T)) {
1977+ fn iter(&self, b: & fn(v: &T)) {
19781978 for vec::each(*self) |elt| { b(elt); }
19791979 }
19801980}
0 commit comments