@@ -70,14 +70,14 @@ fn compute_distance(p1: &point, p2: &point) -> float {
70
70
71
71
Now we can call ` compute_distance() ` in various ways:
72
72
73
- ~~~ {.xfail-test}
73
+ ~~~
74
74
# type point = {x: float, y: float};
75
75
# let on_the_stack : point = {x: 3.0, y: 4.0};
76
76
# let shared_box : @point = @{x: 5.0, y: 1.0};
77
77
# let unique_box : ~point = ~{x: 7.0, y: 9.0};
78
78
# fn compute_distance(p1: &point, p2: &point) -> float { 0f }
79
- compute_distance(&on_the_stack, shared_box)
80
- compute_distance(shared_box, unique_box)
79
+ compute_distance(&on_the_stack, shared_box);
80
+ compute_distance(shared_box, unique_box);
81
81
~~~
82
82
83
83
Here the ` & ` operator is used to take the address of the variable
@@ -147,21 +147,21 @@ type rectangle = {origin: point, size: size};
147
147
Now again I can define rectangles in a few different ways:
148
148
149
149
~~~
150
- let rect_stack = &{origin: {x: 1 , y: 2 }, size: {w: 3 , h: 4 }};
151
- let rect_shared = @{origin: {x: 3 , y: 4 }, size: {w: 3 , h: 4 }};
152
- let rect_unique = ~{origin: {x: 5 , y: 6 }, size: {w: 3 , h: 4 }};
150
+ let rect_stack = &{origin: {x: 1f , y: 2f }, size: {w: 3f , h: 4f }};
151
+ let rect_shared = @{origin: {x: 3f , y: 4f }, size: {w: 3f , h: 4f }};
152
+ let rect_unique = ~{origin: {x: 5f , y: 6f }, size: {w: 3f , h: 4f }};
153
153
~~~
154
154
155
155
In each case I can use the ` & ` operator to extact out individual
156
156
subcomponents. For example, I could write:
157
157
158
- ~~~ {.xfail-test}
158
+ ~~~
159
159
# type point = {x: float, y: float};
160
160
# type size = {w: float, h: float}; // as before
161
161
# type rectangle = {origin: point, size: size};
162
- # let rect_stack = &{origin: {x: 1 , y: 2 }, size: {w: 3 , h: 4 }};
163
- # let rect_shared = @{origin: {x: 3 , y: 4 }, size: {w: 3 , h: 4 }};
164
- # let rect_unique = ~{origin: {x: 5 , y: 6 }, size: {w: 3 , h: 4 }};
162
+ # let rect_stack = &{origin: {x: 1f , y: 2f }, size: {w: 3f , h: 4f }};
163
+ # let rect_shared = @{origin: {x: 3f , y: 4f }, size: {w: 3f , h: 4f }};
164
+ # let rect_unique = ~{origin: {x: 5f , y: 6f }, size: {w: 3f , h: 4f }};
165
165
# fn compute_distance(p1: &point, p2: &point) -> float { 0f }
166
166
compute_distance(&rect_stack.origin, &rect_shared.origin);
167
167
~~~
0 commit comments