Skip to content

Commit 3bfa050

Browse files
committed
auto merge of #13329 : ckendell/rust/remmanaged_tutorial, r=brson
Fixes #13287 Completes work started in #13298 Removed all reference to and sample code using managed boxes/pointers.
2 parents 339d400 + dab5de2 commit 3bfa050

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

src/doc/tutorial.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1492,8 +1492,8 @@ Rust uses the unary star operator (`*`) to access the contents of a
14921492
box or pointer, similarly to C.
14931493
14941494
~~~
1495-
let owned = ~20;
1496-
let borrowed = &30;
1495+
let owned = ~10;
1496+
let borrowed = &20;
14971497

14981498
let sum = *owned + *borrowed;
14991499
~~~
@@ -1520,7 +1520,7 @@ can sometimes make code awkward and parenthesis-filled.
15201520
# struct Point { x: f64, y: f64 }
15211521
# enum Shape { Rectangle(Point, Point) }
15221522
# impl Shape { fn area(&self) -> int { 0 } }
1523-
let start = @Point { x: 10.0, y: 20.0 };
1523+
let start = ~Point { x: 10.0, y: 20.0 };
15241524
let end = ~Point { x: (*start).x + 100.0, y: (*start).y + 100.0 };
15251525
let rect = &Rectangle(*start, *end);
15261526
let area = (*rect).area();
@@ -1534,7 +1534,7 @@ dot), so in most cases, explicitly dereferencing the receiver is not necessary.
15341534
# struct Point { x: f64, y: f64 }
15351535
# enum Shape { Rectangle(Point, Point) }
15361536
# impl Shape { fn area(&self) -> int { 0 } }
1537-
let start = @Point { x: 10.0, y: 20.0 };
1537+
let start = ~Point { x: 10.0, y: 20.0 };
15381538
let end = ~Point { x: start.x + 100.0, y: start.y + 100.0 };
15391539
let rect = &Rectangle(*start, *end);
15401540
let area = rect.area();
@@ -1546,7 +1546,7 @@ something silly like
15461546
15471547
~~~
15481548
# struct Point { x: f64, y: f64 }
1549-
let point = &@~Point { x: 10.0, y: 20.0 };
1549+
let point = &~Point { x: 10.0, y: 20.0 };
15501550
println!("{:f}", point.x);
15511551
~~~
15521552
@@ -1907,7 +1907,6 @@ to a reference.
19071907
// As with typical function arguments, owned pointers
19081908
// are automatically converted to references
19091909

1910-
(@s).draw_reference();
19111910
(~s).draw_reference();
19121911

19131912
// Unlike typical function arguments, the self value will
@@ -1918,7 +1917,7 @@ s.draw_reference();
19181917
(& &s).draw_reference();
19191918

19201919
// ... and dereferenced and borrowed
1921-
(&@~s).draw_reference();
1920+
(&~s).draw_reference();
19221921
~~~
19231922
19241923
Implementations may also define standalone (sometimes called "static")
@@ -2403,7 +2402,7 @@ that, like strings and vectors, objects have dynamic size and may
24032402
only be referred to via one of the pointer types.
24042403
Other pointer types work as well.
24052404
Casts to traits may only be done with compatible pointers so,
2406-
for example, an `@Circle` may not be cast to an `~Drawable`.
2405+
for example, an `&Circle` may not be cast to an `~Drawable`.
24072406
24082407
~~~
24092408
# type Circle = int; type Rectangle = int;
@@ -2506,8 +2505,8 @@ use std::f64::consts::PI;
25062505
# impl Circle for CircleStruct { fn radius(&self) -> f64 { (self.area() / PI).sqrt() } }
25072506
# impl Shape for CircleStruct { fn area(&self) -> f64 { PI * square(self.radius) } }
25082507
2509-
let concrete = @CircleStruct{center:Point{x:3.0,y:4.0},radius:5.0};
2510-
let mycircle: @Circle = concrete as @Circle;
2508+
let concrete = ~CircleStruct{center:Point{x:3.0,y:4.0},radius:5.0};
2509+
let mycircle: ~Circle = concrete as ~Circle;
25112510
let nonsense = mycircle.radius() * mycircle.area();
25122511
~~~
25132512

0 commit comments

Comments
 (0)