@@ -1014,11 +1014,11 @@ let my_shape = circle({x: 0.0, y: 0.0}, 10.0);
1014
1014
1015
1015
## Records
1016
1016
1017
- Rust record types are written ` {field1: TYPE , field2: TYPE [, ...]} ` ,
1018
- and record literals are written in the same way, but with expressions
1019
- instead of types. They are quite similar to C structs, and even laid
1020
- out the same way in memory (so you can read from a Rust struct in C,
1021
- and vice-versa).
1017
+ Rust record types are written ` {field1: T1 , field2: T2 [, ...]} ` ,
1018
+ where ` T1 ` , ` T2 ` , ... denote types. Record literals are written in
1019
+ the same way, but with expressions instead of types. They are quite
1020
+ similar to C structs, and even laid out the same way in memory (so you
1021
+ can read from a Rust struct in C, and vice-versa).
1022
1022
1023
1023
The dot operator is used to access record fields (` mypoint.x ` ).
1024
1024
@@ -1220,10 +1220,10 @@ records with mutable fields, it can be useful to have a single copy on
1220
1220
the heap, and refer to that through a pointer.
1221
1221
1222
1222
Rust supports several types of pointers. The simplest is the unsafe
1223
- pointer, written ` *TYPE ` , which is a completely unchecked pointer
1224
- type only used in unsafe code (and thus, in typical Rust code, very
1225
- rarely). The safe pointer types are ` @TYPE ` for shared,
1226
- reference-counted boxes, and ` ~TYPE ` , for uniquely-owned pointers.
1223
+ pointer, written ` *T ` , which is a completely unchecked pointer type
1224
+ only used in unsafe code (and thus, in typical Rust code, very
1225
+ rarely). The safe pointer types are ` @T ` for shared, reference-counted
1226
+ boxes, and ` ~T ` , for uniquely-owned pointers.
1227
1227
1228
1228
All pointer types can be dereferenced with the ` * ` unary operator.
1229
1229
@@ -1272,9 +1272,9 @@ become the sole owner of the box.
1272
1272
1273
1273
### Mutability
1274
1274
1275
- All pointer types have a mutable variant, written ` @mut TYPE ` or
1276
- ` ~mut TYPE ` . Given such a pointer, you can write to its contents
1277
- by combining the dereference operator with a mutating action.
1275
+ All pointer types have a mutable variant, written ` @mut T ` or ` ~ mut
1276
+ T` . Given such a pointer, you can write to its contents by combining
1277
+ the dereference operator with a mutating action.
1278
1278
1279
1279
~~~~
1280
1280
fn increase_contents(pt: @mut int) {
@@ -1285,8 +1285,8 @@ fn increase_contents(pt: @mut int) {
1285
1285
## Vectors
1286
1286
1287
1287
Rust vectors are always heap-allocated and unique. A value of type
1288
- ` [TYPE ] ` is represented by a pointer to a section of heap memory
1289
- containing any number of ` TYPE ` values .
1288
+ ` [T ] ` is represented by a pointer to a section of heap memory
1289
+ containing any number of values of type ` T ` .
1290
1290
1291
1291
NOTE: This uniqueness is turning out to be quite awkward in practice,
1292
1292
and might change in the future.
@@ -1300,9 +1300,9 @@ if myvec[1] { io::println("boom"); }
1300
1300
~~~~
1301
1301
1302
1302
By default, vectors are immutable—you can not replace their elements.
1303
- The type written as ` [mut TYPE ] ` is a vector with mutable
1304
- elements. Mutable vector literals are written ` [mut] ` (empty) or
1305
- ` [mut 1, 2, 3]` (with elements).
1303
+ The type written as ` [mut T ] ` is a vector with mutable
1304
+ elements. Mutable vector literals are written ` [mut] ` (empty) or ` [ mut
1305
+ 1, 2, 3] ` (with elements).
1306
1306
1307
1307
The ` + ` operator means concatenation when applied to vector types.
1308
1308
Growing a vector in Rust is not as inefficient as it looks :
0 commit comments