File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -1019,6 +1019,12 @@ To create a new record based on the value of an existing record
1019
1019
you construct it using the ` with ` keyword:
1020
1020
1021
1021
~~~~
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
+
1022
1028
let oldpoint = {x: 10f, y: 20f};
1023
1029
let newpoint = {x: 0f with oldpoint};
1024
1030
assert newpoint == {x: 0f, y: 20f};
@@ -1437,7 +1443,10 @@ also done with square brackets (zero-based):
1437
1443
# fn draw_scene(c: crayon) { }
1438
1444
1439
1445
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
+ }
1441
1450
~~~~
1442
1451
1443
1452
By default, vectors are immutable—you can not replace their elements.
You can’t perform that action at this time.
0 commit comments