Skip to content

Commit 9ec2193

Browse files
committed
doc: Tutorial fixes
Thanks to Mohd. Bilal Husain
1 parent efe4c6a commit 9ec2193

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

doc/tutorial.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1623,10 +1623,9 @@ The previous section mentioned that arguments are passed by pointer or
16231623
by value based on their type. There is one situation in which this is
16241624
difficult. If you try this program:
16251625

1626-
~~~~
1627-
# fn map(f: fn(int) -> int, v: [int]) {}
1626+
~~~~{.xfail-test}
16281627
fn plus1(x: int) -> int { x + 1 }
1629-
map(plus1, [1, 2, 3]);
1628+
vec::map([1, 2, 3], plus1);
16301629
~~~~
16311630

16321631
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,
16391638
using the `&&` sigil:
16401639

16411640
~~~~
1642-
# fn map<T, U>(f: fn(T) -> U, v: [T]) {}
16431641
fn plus1(&&x: int) -> int { x + 1 }
1644-
map(plus1, [1, 2, 3]);
1642+
vec::map([1, 2, 3], plus1);
16451643
~~~~
16461644

16471645
NOTE: This is inconvenient, and we are hoping to get rid of this
@@ -2134,7 +2132,7 @@ native mod crypto {
21342132
}
21352133
21362134
fn as_hex(data: [u8]) -> str {
2137-
let acc = "";
2135+
let mut acc = "";
21382136
for byte in data { acc += #fmt("%02x", byte as uint); }
21392137
ret acc;
21402138
}
@@ -2517,14 +2515,16 @@ The Rust language has a facility for testing built into the language.
25172515
Tests can be interspersed with other code, and annotated with the
25182516
`#[test]` attribute.
25192517

2520-
~~~~
2518+
~~~~{.xfail-test}
2519+
# // FIXME: xfailed because test_twice is a #[test] function it's not
2520+
# // getting compiled
25212521
use std;
25222522
25232523
fn twice(x: int) -> int { x + x }
25242524
25252525
#[test]
25262526
fn test_twice() {
2527-
let i = -100;
2527+
let mut i = -100;
25282528
while i < 100 {
25292529
assert twice(i) == 2 * i;
25302530
i += 1;

0 commit comments

Comments
 (0)