Skip to content

Commit a3295ab

Browse files
committed
---
yaml --- r: 40943 b: refs/heads/dist-snap c: f15ccc0 h: refs/heads/master i: 40941: 8daca38 40939: c845160 40935: 6c47d22 40927: e59c756 v: v3
1 parent d31d139 commit a3295ab

File tree

2 files changed

+10
-20
lines changed

2 files changed

+10
-20
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: a810c03263670238bccd64cabb12a23a46e3a278
99
refs/heads/incoming: e90142e536c150df0d9b4b2f11352152177509b5
10-
refs/heads/dist-snap: 41870da5ad9d995d915ff24560ce269f8fa79690
10+
refs/heads/dist-snap: f15ccc06f063c1c31c769650b8b73a0d0c452113
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1313
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/doc/tutorial.md

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,13 +1124,16 @@ _exchange heap_, where their uniquely-owned nature allows tasks to
11241124
exchange them efficiently.
11251125

11261126
Because owned boxes are uniquely owned, copying them requires allocating
1127-
a new owned box and duplicating the contents. Copying owned boxes
1128-
is expensive so the compiler will complain if you do so without writing
1129-
the word `copy`.
1127+
a new owned box and duplicating the contents.
1128+
Instead, owned boxes are _moved_ by default, transferring ownership,
1129+
and deinitializing the previously owning variable.
1130+
Any attempt to access a variable after the value has been moved out
1131+
will result in a compile error.
11301132

11311133
~~~~
11321134
let x = ~10;
1133-
let y = x; // error: copying a non-implicitly copyable type
1135+
// Move x to y, deinitializing x
1136+
let y = x;
11341137
~~~~
11351138

11361139
If you really want to copy an owned box you must say so explicitly.
@@ -1143,19 +1146,6 @@ let z = *x + *y;
11431146
assert z == 20;
11441147
~~~~
11451148

1146-
This is where the 'move' operator comes in. It is similar to `copy`,
1147-
but it de-initializes its source. Thus, the owned box can move from
1148-
`x` to `y`, without violating the constraint that it only has a single
1149-
owner (using assignment instead of the move operator would, in
1150-
principle, copy the box).
1151-
1152-
~~~~ {.xfail-test}
1153-
let x = ~10;
1154-
let y = move x;
1155-
1156-
let z = *x + *y; // would cause an error: use of moved variable: `x`
1157-
~~~~
1158-
11591149
Owned boxes, when they do not contain any managed boxes, can be sent
11601150
to other tasks. The sending task will give up ownership of the box,
11611151
and won't be able to access it afterwards. The receiving task will
@@ -1360,7 +1350,7 @@ let your_crayons = ~[BananaMania, Beaver, Bittersweet];
13601350
let our_crayons = my_crayons + your_crayons;
13611351
13621352
// += will append to a vector, provided it lives in a mutable slot
1363-
let mut my_crayons = move my_crayons;
1353+
let mut my_crayons = my_crayons;
13641354
my_crayons += your_crayons;
13651355
~~~~
13661356
@@ -1899,7 +1889,7 @@ fn map<T, U>(vector: &[T], function: fn(v: &T) -> U) -> ~[U] {
18991889
for vec::each(vector) |element| {
19001890
accumulator.push(function(element));
19011891
}
1902-
return (move accumulator);
1892+
return accumulator;
19031893
}
19041894
~~~~
19051895

0 commit comments

Comments
 (0)