Skip to content

Commit 3a2e9e4

Browse files
committed
manual: s/unique/owned/, s/shared/managed/, fix rval/lval more.
1 parent d882274 commit 3a2e9e4

File tree

1 file changed

+40
-40
lines changed

1 file changed

+40
-40
lines changed

doc/rust.md

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,12 +1479,12 @@ The evaluation of an expression depends both on its own category and the context
14791479
[Path](#path-expressions), [field](#field-expressions) and [index](#index-expressions) expressions are lvalues.
14801480
All other expressions are rvalues.
14811481

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
14831484
[compound-assignment](#compound-assignment-expressions) expression is an lvalue context,
14841485
as is the single operand of a unary [borrow](#unary-operator-expressions),
14851486
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.
14881488
All other expression contexts are rvalue contexts.
14891489

14901490
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`.
17371737
The binary comparison operators can be applied to any two operands of
17381738
the same type, and produce a boolean value.
17391739

1740-
*TODO* details on how types are descended during comparison.
1741-
17421740
#### Type cast expressions
17431741

17441742
A type cast expression is denoted with the binary operator `as`.
@@ -1774,15 +1772,16 @@ types.
17741772
A _binary move expression_ consists of an [lvalue](#lvalues-rvalues-and-temporaries) followed by a left-pointing
17751773
arrow (`<-`) and an [rvalue](#lvalues-rvalues-and-temporaries) expression.
17761774

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.
17801779

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.
17861785

17871786
An example of three different move expressions:
17881787

@@ -1805,8 +1804,10 @@ A _swap expression_ consists of an [lvalue](#lvalues-rvalues-and-temporaries) fo
18051804

18061805
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.
18071806

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.
18101811
No allocation or destruction is entailed.
18111812

18121813
An example of three different swap expressions:
@@ -1904,13 +1905,12 @@ Evaluating a copy expression first evaluates the argument expression, then
19041905
copies the resulting value, allocating any memory necessary to hold the new
19051906
copy.
19061907

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.
19101911

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.
19141914

19151915
An example of a copy expression:
19161916

@@ -2670,15 +2670,15 @@ kinds are:
26702670

26712671
Sendable
26722672
: 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
26742674
structural types containing only other sendable types.
26752675
Copyable
26762676
: 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,
26782678
trait types, and structural types built out of these.
26792679
Noncopyable
26802680
: [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.
26822682
Types of sendable or copyable type can always be used in places
26832683
where a noncopyable type is expected, so in effect this kind
26842684
includes all types.
@@ -2696,7 +2696,7 @@ declared for it. For example, this is not a valid program:
26962696
fn box<T>(x: T) -> @T { @x }
26972697
~~~~
26982698

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
27002700
is assumed to be noncopyable. To change that, a bound is declared:
27012701

27022702
~~~~
@@ -2746,7 +2746,7 @@ entry to each function as the task executes. A stack allocation is reclaimed
27462746
when control leaves the frame containing it.
27472747

27482748
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
27502750
boxes. The lifetime of an allocation in the heap depends on the lifetime of
27512751
the box values pointing to it. Since box values may themselves be passed in
27522752
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
27652765
never including managed or borrowed pointers.
27662766

27672767
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.
27692769

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
27722772
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.
27752775

27762776
When a task finishes, its stack is necessarily empty and it therefore has no
27772777
references to any boxes; the remainder of its heap is immediately freed.
@@ -2820,22 +2820,22 @@ fn incr(i: &mut int) {
28202820
### Memory boxes
28212821

28222822
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*.
28242824

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 `@`.
28262826

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 `~`.
28282828

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
28322832
reference-counting).
28332833

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
28362836
produces a pointer to the new allocation.
28372837

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
28392839
type and value:
28402840

28412841
~~~~~~~~

0 commit comments

Comments
 (0)