Skip to content

Commit ee37f8a

Browse files
committed
Fix up the tutorial doc-tests.
1 parent 6e7d5e1 commit ee37f8a

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

doc/tutorial.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1019,6 +1019,12 @@ To create a new record based on the value of an existing record
10191019
you construct it using the `with` keyword:
10201020

10211021
~~~~
1022+
# impl {x:float, y:float} : core::cmp::Eq {
1023+
# pure fn eq(&&other: {x:float, y:float}) -> bool {
1024+
# self.x == other.x && self.y == other.y
1025+
# }
1026+
# }
1027+
10221028
let oldpoint = {x: 10f, y: 20f};
10231029
let newpoint = {x: 0f with oldpoint};
10241030
assert newpoint == {x: 0f, y: 20f};
@@ -1437,7 +1443,10 @@ also done with square brackets (zero-based):
14371443
# fn draw_scene(c: crayon) { }
14381444
14391445
let crayons = ~[banana_mania, beaver, bittersweet];
1440-
if crayons[0] == bittersweet { draw_scene(crayons[0]); }
1446+
match crayons[0] {
1447+
bittersweet => draw_scene(crayons[0]),
1448+
_ => ()
1449+
}
14411450
~~~~
14421451

14431452
By default, vectors are immutable—you can not replace their elements.

0 commit comments

Comments
 (0)