@@ -1408,20 +1408,17 @@ struct Point {
1408
1408
~~~~
1409
1409
1410
1410
We can use this simple definition to allocate points in many different
1411
- ways. For example, in this code, each of these three local variables
1411
+ ways. For example, in this code, each of these local variables
1412
1412
contains a point, but allocated in a different location:
1413
1413
1414
1414
~~~
1415
1415
# struct Point { x: f64, y: f64 }
1416
1416
let on_the_stack : Point = Point { x: 3.0, y: 4.0 };
1417
- let managed_box : @Point = @Point { x: 5.0, y: 1.0 };
1418
1417
let owned_box : ~ Point = ~ Point { x: 7.0, y: 9.0 };
1419
1418
~~~
1420
1419
1421
1420
Suppose we want to write a procedure that computes the distance
1422
- between any two points, no matter where they are stored. For example,
1423
- we might like to compute the distance between `on_the_stack` and
1424
- `managed_box`, or between `managed_box` and `owned_box`. One option is
1421
+ between any two points, no matter where they are stored. One option is
1425
1422
to define a function that takes two arguments of type point—that is,
1426
1423
it takes the points by value. But this will cause the points to be
1427
1424
copied when we call the function. For points, this is probably not so
@@ -1442,11 +1439,9 @@ Now we can call `compute_distance()` in various ways:
1442
1439
~~~
1443
1440
# struct Point{ x: f64, y: f64 };
1444
1441
# let on_the_stack : Point = Point { x: 3.0, y: 4.0 };
1445
- # let managed_box : @Point = @Point { x: 5.0, y: 1.0 };
1446
1442
# let owned_box : ~ Point = ~ Point { x: 7.0, y: 9.0 };
1447
1443
# fn compute_distance(p1: &Point, p2: &Point) -> f64 { 0.0 }
1448
- compute_distance(&on_the_stack, managed_box);
1449
- compute_distance(managed_box, owned_box);
1444
+ compute_distance(&on_the_stack, owned_box);
1450
1445
~~~
1451
1446
1452
1447
Here the `&` operator is used to take the address of the variable
@@ -1456,11 +1451,11 @@ reference. We also call this _borrowing_ the local variable
1456
1451
`on_the_stack`, because we are creating an alias: that is, another
1457
1452
route to the same data.
1458
1453
1459
- In the case of the boxes `managed_box` and `owned_box`, however, no
1454
+ In the case of `owned_box`, however, no
1460
1455
explicit action is necessary. The compiler will automatically convert
1461
- a box like `@point` or `~point` to a reference like
1456
+ a box `~point` to a reference like
1462
1457
`&point`. This is another form of borrowing; in this case, the
1463
- contents of the managed/ owned box are being lent out.
1458
+ contents of the owned box are being lent out.
1464
1459
1465
1460
Whenever a value is borrowed, there are some limitations on what you
1466
1461
can do with the original. For example, if the contents of a variable
@@ -1497,26 +1492,24 @@ Rust uses the unary star operator (`*`) to access the contents of a
1497
1492
box or pointer, similarly to C.
1498
1493
1499
1494
~~~
1500
- let managed = @10 ;
1501
1495
let owned = ~ 20;
1502
1496
let borrowed = &30;
1503
1497
1504
- let sum = * managed + * owned + * borrowed;
1498
+ let sum = * owned + * borrowed;
1505
1499
~~~
1506
1500
1507
1501
Dereferenced mutable pointers may appear on the left hand side of
1508
1502
assignments. Such an assignment modifies the value that the pointer
1509
1503
points to.
1510
1504
1511
1505
~~~
1512
- let managed = @10 ;
1513
- let mut owned = ~ 20;
1506
+ let mut owned = ~ 10;
1514
1507
1515
- let mut value = 30 ;
1508
+ let mut value = 20 ;
1516
1509
let borrowed = &mut value;
1517
1510
1518
1511
* owned = * borrowed + 100;
1519
- * borrowed = * managed + 1000;
1512
+ * borrowed = * owned + 1000;
1520
1513
~~~
1521
1514
1522
1515
Pointers have high operator precedence, but lower precedence than the
@@ -1911,7 +1904,7 @@ to a reference.
1911
1904
# fn draw_value(self) { /* ... * / }
1912
1905
# }
1913
1906
# let s = Circle(Point { x: 1.0, y: 2.0 }, 3.0);
1914
- // As with typical function arguments, managed and owned pointers
1907
+ // As with typical function arguments, owned pointers
1915
1908
// are automatically converted to references
1916
1909
1917
1910
(@s ).draw_reference();
@@ -2094,7 +2087,7 @@ and may not be overridden:
2094
2087
2095
2088
* `Send` - Sendable types.
2096
2089
Types are sendable
2097
- unless they contain managed boxes, managed closures, or references.
2090
+ unless they contain managed closures or references.
2098
2091
2099
2092
* `Share` - Types that are *threadsafe*
2100
2093
These are types that are safe to be used across several threads with access to
0 commit comments