Skip to content

Commit da5033f

Browse files
committed
Make a few more borrowed pointer tutorial examples pass
1 parent 864cca1 commit da5033f

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

doc/tutorial-borrowed-ptr.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,14 @@ fn compute_distance(p1: &point, p2: &point) -> float {
7070

7171
Now we can call `compute_distance()` in various ways:
7272

73-
~~~ {.xfail-test}
73+
~~~
7474
# type point = {x: float, y: float};
7575
# let on_the_stack : point = {x: 3.0, y: 4.0};
7676
# let shared_box : @point = @{x: 5.0, y: 1.0};
7777
# let unique_box : ~point = ~{x: 7.0, y: 9.0};
7878
# 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);
8181
~~~
8282

8383
Here the `&` operator is used to take the address of the variable
@@ -147,21 +147,21 @@ type rectangle = {origin: point, size: size};
147147
Now again I can define rectangles in a few different ways:
148148

149149
~~~
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}};
153153
~~~
154154

155155
In each case I can use the `&` operator to extact out individual
156156
subcomponents. For example, I could write:
157157

158-
~~~ {.xfail-test}
158+
~~~
159159
# type point = {x: float, y: float};
160160
# type size = {w: float, h: float}; // as before
161161
# 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}};
165165
# fn compute_distance(p1: &point, p2: &point) -> float { 0f }
166166
compute_distance(&rect_stack.origin, &rect_shared.origin);
167167
~~~

0 commit comments

Comments
 (0)