@@ -19,7 +19,7 @@ Version: @gitversion
19
19
20
20
Copyright 2006-2010 Graydon Hoare
21
21
22
- Copyright 2009-2010 Mozilla Foundation
22
+ Copyright 2009-2011 Mozilla Foundation
23
23
24
24
See accompanying LICENSE.txt for terms.
25
25
@@ -192,12 +192,12 @@ subsumed into the more general facility of disjoint union types. A program
192
192
must explicitly model its use of such types.
193
193
194
194
@sp 1
195
- @item Lightweight tasks with no shared mutable state
195
+ @item Lightweight tasks with no shared values
196
196
197
197
Like many @emph {actor } languages, Rust provides an isolation (and concurrency)
198
198
model based on lightweight tasks scheduled by the language runtime. These
199
- tasks are very inexpensive and statically unable to mutate one another's local
200
- memory. Breaking the rule of task isolation is only possible by calling
199
+ tasks are very inexpensive and statically unable to manipulate one another's
200
+ local memory. Breaking the rule of task isolation is only possible by calling
201
201
external (C/C++) code.
202
202
203
203
Inter-task communication is typed, asynchronous and simplex, based on passing
@@ -247,10 +247,11 @@ roles.
247
247
@item Static control over memory allocation, packing and aliasing.
248
248
249
249
Many values in Rust are allocated @emph {within } their containing stack-frame
250
- or parent structure. Numbers, records, tuples and tags are all allocated this
250
+ or parent structure. Numbers, records and tags are all allocated this
251
251
way. To allocate such values in the heap, they must be explicitly
252
252
@emph {boxed }. A @dfn {box } is a pointer to a heap allocation that holds another
253
- value, its @emph {content }.
253
+ value, its @emph {content }. Boxes may be either shared or unique, depending
254
+ on which sort of storage management is desired.
254
255
255
256
Boxing and unboxing in Rust is explicit, though in many cases (arithmetic
256
257
operations, name-component dereferencing) Rust will automatically ``reach
@@ -273,42 +274,29 @@ still guaranteeing that every use of a slot occurs after it has been
273
274
initialized.
274
275
275
276
@sp 1
276
- @item Static control over mutability and garbage collection.
277
+ @item Immutable data by default
277
278
278
- Types in Rust are classified into @emph {layers }. There is a layer of immutable
279
- values, a layer of state values, and a layer of GC values. By default, all
280
- types are immutable.
279
+ All types in Rust are immutable by default. A field within a type must be
280
+ declared as @code {mutable } in order to be modified.
281
281
282
- If a field within a type is declared as @code {mutable }, then the type is part
283
- of the @code {state } layer and must be declared as such. Any type directly
284
- marked as @code {state } @emph {or indirectly referring to } a state type is also
285
- a state type.
286
-
287
- If a field within a type is potentially cyclic (this is a narrow, but
288
- well-defined condition involving mutable recursive types) then it is part of
289
- the @code {gc } layer and must be declared as such.
290
-
291
- This classification of data types in Rust interacts with the memory allocation,
292
- transmission and destruction rules. In particular:
293
-
294
- @itemize
295
- @item Only immutable values can be sent over channels.
296
- @item Only non-GC objects can have destructor functions.
297
- @end itemize
298
-
299
- Garbage collection, when present, operates per-task and does not interrupt
300
- other tasks while running. It is limited to types that need it and can be
301
- statically avoided altogether by limiting the types in a program to the state
302
- and immutable layers.
303
-
304
- Non-GC values are reference-counted and have a deterministic destruction
305
- order: top-down, immediately upon release of the last live reference.
306
-
307
- State values can refer to non-state values, but not vice-versa; likewise GC
308
- values can refer to non-GC values but not vice-versa. Rust therefore
309
- encourages the programmer to write in a style that consists primarily of
310
- immutable types, but also permits limited, local (per-task) mutability,
311
- and provides local (per-task) GC only when required.
282
+ @sp 1
283
+ @item Move semantics and unique pointers
284
+
285
+ Rust differentiates copying values from moving them, and permits moving and
286
+ swapping values explicitly rather than copying. Moving can be more efficient and,
287
+ crucially, represents an indivisible transfer of ownership of a value from its
288
+ source to its destination.
289
+
290
+ In addition, pointer types in Rust come in several varieties. One important
291
+ type of pointer related to move semantics is the @emph {unique } pointer,
292
+ denoted @code {~ }, which is statically guaranteed to be the only pointer
293
+ pointing to its referent at any given time.
294
+
295
+ Combining move-semantics and unique pointers, Rust permits a very lightweight
296
+ form of inter-task communication: values are sent between tasks by moving, and
297
+ only types composed of unique pointers can be sent. This statically ensures
298
+ there can never be sharing of data between tasks, while keeping the costs of
299
+ transferring data between tasks as cheap as moving a pointer.
312
300
313
301
@sp 1
314
302
@item Stack-based iterators
0 commit comments