@@ -1623,10 +1623,9 @@ The previous section mentioned that arguments are passed by pointer or
1623
1623
by value based on their type. There is one situation in which this is
1624
1624
difficult. If you try this program:
1625
1625
1626
- ~~~~
1627
- # fn map(f: fn(int) -> int, v: [int]) {}
1626
+ ~~~~ {.xfail-test}
1628
1627
fn plus1(x: int) -> int { x + 1 }
1629
- map(plus1, [1, 2, 3]);
1628
+ vec:: map([1, 2, 3], plus1 );
1630
1629
~~~~
1631
1630
1632
1631
You will get an error message about argument passing styles
@@ -1639,9 +1638,8 @@ pass to a generic higher-order function as being passed by pointer,
1639
1638
using the ` && ` sigil:
1640
1639
1641
1640
~~~~
1642
- # fn map<T, U>(f: fn(T) -> U, v: [T]) {}
1643
1641
fn plus1(&&x: int) -> int { x + 1 }
1644
- map(plus1, [1, 2, 3]);
1642
+ vec:: map([1, 2, 3], plus1 );
1645
1643
~~~~
1646
1644
1647
1645
NOTE: This is inconvenient, and we are hoping to get rid of this
@@ -2134,7 +2132,7 @@ native mod crypto {
2134
2132
}
2135
2133
2136
2134
fn as_hex(data: [u8]) -> str {
2137
- let acc = "";
2135
+ let mut acc = "";
2138
2136
for byte in data { acc += #fmt("%02x", byte as uint); }
2139
2137
ret acc;
2140
2138
}
@@ -2517,14 +2515,16 @@ The Rust language has a facility for testing built into the language.
2517
2515
Tests can be interspersed with other code, and annotated with the
2518
2516
` #[test] ` attribute.
2519
2517
2520
- ~~~~
2518
+ ~~~~ {.xfail-test}
2519
+ # // FIXME: xfailed because test_twice is a #[test] function it's not
2520
+ # // getting compiled
2521
2521
use std;
2522
2522
2523
2523
fn twice(x: int) -> int { x + x }
2524
2524
2525
2525
#[test]
2526
2526
fn test_twice() {
2527
- let i = -100;
2527
+ let mut i = -100;
2528
2528
while i < 100 {
2529
2529
assert twice(i) == 2 * i;
2530
2530
i += 1;
0 commit comments