@@ -1492,8 +1492,8 @@ Rust uses the unary star operator (`*`) to access the contents of a
1492
1492
box or pointer, similarly to C.
1493
1493
1494
1494
~~~
1495
- let owned = ~ 20 ;
1496
- let borrowed = &30 ;
1495
+ let owned = ~ 10 ;
1496
+ let borrowed = &20 ;
1497
1497
1498
1498
let sum = * owned + * borrowed;
1499
1499
~~~
@@ -1520,7 +1520,7 @@ can sometimes make code awkward and parenthesis-filled.
1520
1520
# struct Point { x: f64, y: f64 }
1521
1521
# enum Shape { Rectangle(Point, Point) }
1522
1522
# 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 };
1524
1524
let end = ~ Point { x: (* start).x + 100.0, y: (* start).y + 100.0 };
1525
1525
let rect = &Rectangle(* start, * end);
1526
1526
let area = (* rect).area();
@@ -1534,7 +1534,7 @@ dot), so in most cases, explicitly dereferencing the receiver is not necessary.
1534
1534
# struct Point { x: f64, y: f64 }
1535
1535
# enum Shape { Rectangle(Point, Point) }
1536
1536
# 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 };
1538
1538
let end = ~ Point { x: start.x + 100.0, y: start.y + 100.0 };
1539
1539
let rect = &Rectangle(* start, * end);
1540
1540
let area = rect.area();
@@ -1546,7 +1546,7 @@ something silly like
1546
1546
1547
1547
~~~
1548
1548
# 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 };
1550
1550
println!("{: f }", point.x);
1551
1551
~~~
1552
1552
@@ -1907,7 +1907,6 @@ to a reference.
1907
1907
// As with typical function arguments, owned pointers
1908
1908
// are automatically converted to references
1909
1909
1910
- (@s ).draw_reference();
1911
1910
(~ s).draw_reference();
1912
1911
1913
1912
// Unlike typical function arguments, the self value will
@@ -1918,7 +1917,7 @@ s.draw_reference();
1918
1917
(& &s).draw_reference();
1919
1918
1920
1919
// ... and dereferenced and borrowed
1921
- (&@ ~ s).draw_reference();
1920
+ (&~ s).draw_reference();
1922
1921
~~~
1923
1922
1924
1923
Implementations may also define standalone (sometimes called "static")
@@ -2403,7 +2402,7 @@ that, like strings and vectors, objects have dynamic size and may
2403
2402
only be referred to via one of the pointer types.
2404
2403
Other pointer types work as well.
2405
2404
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`.
2407
2406
2408
2407
~~~
2409
2408
# type Circle = int; type Rectangle = int;
@@ -2506,8 +2505,8 @@ use std::f64::consts::PI;
2506
2505
# impl Circle for CircleStruct { fn radius(&self) -> f64 { (self.area() / PI).sqrt() } }
2507
2506
# impl Shape for CircleStruct { fn area(&self) -> f64 { PI * square(self.radius) } }
2508
2507
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;
2511
2510
let nonsense = mycircle.radius() * mycircle.area();
2512
2511
~~~
2513
2512
0 commit comments