You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: branches/incoming/doc/rust.md
+40-40Lines changed: 40 additions & 40 deletions
Original file line number
Diff line number
Diff line change
@@ -1479,12 +1479,12 @@ The evaluation of an expression depends both on its own category and the context
1479
1479
[Path](#path-expressions), [field](#field-expressions) and [index](#index-expressions) expressions are lvalues.
1480
1480
All other expressions are rvalues.
1481
1481
1482
-
The left operand of an [assignment](#assignment-expressions) or
1482
+
The left operand of an [assignment](#assignment-expressions),
1483
+
[binary move](#binary-move-expressions) or
1483
1484
[compound-assignment](#compound-assignment-expressions) expression is an lvalue context,
1484
1485
as is the single operand of a unary [borrow](#unary-operator-expressions),
1485
1486
or [move](#unary-move-expressions) expression,
1486
-
and _both_ operands of a [swap](#swap-expressions)
1487
-
or [binary move](#binary-move-expressions) expression.
1487
+
and _both_ operands of a [swap](#swap-expressions) expression.
1488
1488
All other expression contexts are rvalue contexts.
1489
1489
1490
1490
When an lvalue is evaluated in an _lvalue context_, it denotes a memory location;
@@ -1737,8 +1737,6 @@ and `&&` only when it evaluates to `true`.
1737
1737
The binary comparison operators can be applied to any two operands of
1738
1738
the same type, and produce a boolean value.
1739
1739
1740
-
*TODO* details on how types are descended during comparison.
1741
-
1742
1740
#### Type cast expressions
1743
1741
1744
1742
A type cast expression is denoted with the binary operator `as`.
@@ -1774,15 +1772,16 @@ types.
1774
1772
A _binary move expression_ consists of an [lvalue](#lvalues-rvalues-and-temporaries) followed by a left-pointing
1775
1773
arrow (`<-`) and an [rvalue](#lvalues-rvalues-and-temporaries) expression.
1776
1774
1777
-
Evaluating a move expression causes, as a side effect, the rvalue to be
1778
-
*moved* into the lvalue. If the rvalue was itself an lvalue, it must be a
1779
-
local variable, as it will be de-initialized in the process.
1775
+
Evaluating a move expression causes, as a side effect,
1776
+
the rvalue to be *moved* into the lvalue.
1777
+
If the rvalue was itself an lvalue, it must be a local variable,
1778
+
as it will be de-initialized in the process.
1780
1779
1781
-
Evaluating a move expression does not change reference counts, nor does it
1782
-
cause a deep copy of any unique structure pointed to by the moved
1783
-
*rval*. Instead, the move expression represents an indivisible *transfer of
1784
-
ownership*from the right-hand-side to the left-hand-side of the
1785
-
expression. No allocation or destruction is entailed.
1780
+
Evaluating a move expression does not change reference counts,
1781
+
nor does it cause a deep copy of any owned structure pointed to by the moved rvalue.
1782
+
Instead, the move expression represents an indivisible *transfer of ownership*
1783
+
from the right-hand-side to the left-hand-side of the expression.
1784
+
No allocation or destruction is entailed.
1786
1785
1787
1786
An example of three different move expressions:
1788
1787
@@ -1805,8 +1804,10 @@ A _swap expression_ consists of an [lvalue](#lvalues-rvalues-and-temporaries) fo
1805
1804
1806
1805
Evaluating a swap expression causes, as a side effect, the values held in the left-hand-side and right-hand-side [lvalues](#lvalues-rvalues-and-temporaries) to be exchanged indivisibly.
1807
1806
1808
-
Evaluating a swap expression neither changes reference counts nor deeply copies any unique structure pointed to by the moved [rvalue](#lvalues-rvalues-and-temporaries).
1809
-
Instead, the swap expression represents an indivisible *exchange of ownership* between the right-hand-side and the left-hand-side of the expression.
1807
+
Evaluating a swap expression neither changes reference counts,
1808
+
nor deeply copies any owned structure pointed to by the moved [rvalue](#lvalues-rvalues-and-temporaries).
1809
+
Instead, the swap expression represents an indivisible *exchange of ownership*,
1810
+
between the right-hand-side and the left-hand-side of the expression.
1810
1811
No allocation or destruction is entailed.
1811
1812
1812
1813
An example of three different swap expressions:
@@ -1904,13 +1905,12 @@ Evaluating a copy expression first evaluates the argument expression, then
1904
1905
copies the resulting value, allocating any memory necessary to hold the new
1905
1906
copy.
1906
1907
1907
-
[Shared boxes](#box-types) (type `@`) are, as usual, shallow-copied, as they
1908
-
may be cyclic. [Unique boxes](#box-types), [vectors](#vector-types) and
1909
-
similar unique types are deep-copied.
1908
+
[Managed boxes](#pointer-types) (type `@`) are, as usual, shallow-copied,
1909
+
as are raw and borrowed pointers.
1910
+
[Owned boxes](#pointer-types), [owned vectors](#vector-types) and similar owned types are deep-copied.
1910
1911
1911
-
Since the binary [assignment operator](#assignment-expressions)`=` performs a
1912
-
copy implicitly, the unary copy operator is typically only used to cause an
1913
-
argument to a function to be copied and passed by value.
1912
+
Since the binary [assignment operator](#assignment-expressions)`=` performs a copy implicitly,
1913
+
the unary copy operator is typically only used to cause an argument to a function to be copied and passed by value.
1914
1914
1915
1915
An example of a copy expression:
1916
1916
@@ -2670,15 +2670,15 @@ kinds are:
2670
2670
2671
2671
Sendable
2672
2672
: Values with a sendable type can be safely sent to another task.
2673
-
This kind includes scalars, unique pointers, unique closures, and
2673
+
This kind includes scalars, owning pointers, owned closures, and
2674
2674
structural types containing only other sendable types.
2675
2675
Copyable
2676
2676
: This kind includes all types that can be copied. All types with
2677
-
sendable kind are copyable, as are shared boxes, shared closures,
2677
+
sendable kind are copyable, as are managed boxes, managed closures,
2678
2678
trait types, and structural types built out of these.
2679
2679
Noncopyable
2680
2680
: [Resource](#resources) types, and every type that includes a
2681
-
resource without storing it in a shared box, may not be copied.
2681
+
resource without storing it in a managed box, may not be copied.
2682
2682
Types of sendable or copyable type can always be used in places
2683
2683
where a noncopyable type is expected, so in effect this kind
2684
2684
includes all types.
@@ -2696,7 +2696,7 @@ declared for it. For example, this is not a valid program:
2696
2696
fn box<T>(x: T) -> @T { @x }
2697
2697
~~~~
2698
2698
2699
-
Putting `x` into a shared box involves copying, and the `T` parameter
2699
+
Putting `x` into a managed box involves copying, and the `T` parameter
2700
2700
is assumed to be noncopyable. To change that, a bound is declared:
2701
2701
2702
2702
~~~~
@@ -2746,7 +2746,7 @@ entry to each function as the task executes. A stack allocation is reclaimed
2746
2746
when control leaves the frame containing it.
2747
2747
2748
2748
The _heap_ is a general term that describes two separate sets of boxes:
2749
-
shared boxes -- which may be subject to garbage collection -- and unique
2749
+
managed boxes -- which may be subject to garbage collection -- and owned
2750
2750
boxes. The lifetime of an allocation in the heap depends on the lifetime of
2751
2751
the box values pointing to it. Since box values may themselves be passed in
2752
2752
and out of frames, or stored in the heap, heap allocations may outlive the
@@ -2765,13 +2765,13 @@ it is only instantiated for (transitively) sendable kinds of data constructor an
2765
2765
never including managed or borrowed pointers.
2766
2766
2767
2767
When a stack frame is exited, its local allocations are all released, and its
2768
-
references to boxes (both shared and owned) are dropped.
2768
+
references to boxes (both managed and owned) are dropped.
2769
2769
2770
-
A shared box may (in the case of a recursive, mutable shared type) be cyclic;
2771
-
in this case the release of memory inside the shared structure may be deferred
2770
+
A managed box may (in the case of a recursive, mutable managed type) be cyclic;
2771
+
in this case the release of memory inside the managed structure may be deferred
2772
2772
until task-local garbage collection can reclaim it. Code can ensure no such
2773
-
delayed deallocation occurs by restricting itself to unique boxes and similar
2774
-
unshared kinds of data.
2773
+
delayed deallocation occurs by restricting itself to owned boxes and similar
2774
+
unmanaged kinds of data.
2775
2775
2776
2776
When a task finishes, its stack is necessarily empty and it therefore has no
2777
2777
references to any boxes; the remainder of its heap is immediately freed.
@@ -2820,22 +2820,22 @@ fn incr(i: &mut int) {
2820
2820
### Memory boxes
2821
2821
2822
2822
A _box_ is a reference to a heap allocation holding another value. There
2823
-
are two kinds of boxes: *shared boxes* and *unique boxes*.
2823
+
are two kinds of boxes: *managed boxes* and *owned boxes*.
2824
2824
2825
-
A _shared box_ type or value is constructed by the prefix *at* sigil `@`.
2825
+
A _managed box_ type or value is constructed by the prefix *at* sigil `@`.
2826
2826
2827
-
A _unique box_ type or value is constructed by the prefix *tilde* sigil `~`.
2827
+
An _owned box_ type or value is constructed by the prefix *tilde* sigil `~`.
2828
2828
2829
-
Multiple shared box values can point to the same heap allocation; copying a
2830
-
shared box value makes a shallow copy of the pointer (optionally incrementing
2831
-
a reference count, if the shared box is implemented through
2829
+
Multiple managed box values can point to the same heap allocation; copying a
2830
+
managed box value makes a shallow copy of the pointer (optionally incrementing
2831
+
a reference count, if the managed box is implemented through
2832
2832
reference-counting).
2833
2833
2834
-
Unique box values exist in 1:1 correspondence with their heap allocation;
2835
-
copying a unique box value makes a deep copy of the heap allocation and
2834
+
Owned box values exist in 1:1 correspondence with their heap allocation;
2835
+
copying an owned box value makes a deep copy of the heap allocation and
2836
2836
produces a pointer to the new allocation.
2837
2837
2838
-
An example of constructing one shared box type and value, and one unique box
2838
+
An example of constructing one managed box type and value, and one owned box
0 commit comments