@@ -100,7 +100,7 @@ If you've fulfilled those prerequisites, something along these lines
100
100
should work.
101
101
102
102
~~~~ {.notrust}
103
- $ wget http://dl.rust-lang.org/dist/rust-0.4.tar.gz
103
+ $ curl -O http://dl.rust-lang.org/dist/rust-0.4.tar.gz
104
104
$ tar -xzf rust-0.4.tar.gz
105
105
$ cd rust-0.4
106
106
$ ./configure
@@ -490,7 +490,7 @@ const MY_STRUCTY_PASSWORD: Password = Password { value: MY_PASSWORD };
490
490
## Operators
491
491
492
492
Rust's set of operators contains very few surprises. Arithmetic is done with
493
- ` * ` , ` / ` , ` % ` , ` + ` , and ` - ` (multiply, divide, remainder, plus, minus ). ` - ` is
493
+ ` * ` , ` / ` , ` % ` , ` + ` , and ` - ` (multiply, divide, take remainder, add, subtract ). ` - ` is
494
494
also a unary prefix operator that negates numbers. As in C, the bit operators
495
495
` >> ` , ` << ` , ` & ` , ` | ` , and ` ^ ` are also supported.
496
496
@@ -608,7 +608,7 @@ a wildcard pattern that matches any single value. The asterisk (`*`)
608
608
is a different wildcard that can match one or more fields in an ` enum `
609
609
variant.
610
610
611
- The patterns in an match arm are followed by a fat arrow, ` => ` , then an
611
+ The patterns in a match arm are followed by a fat arrow, ` => ` , then an
612
612
expression to evaluate. Each case is separated by commas. It's often
613
613
convenient to use a block expression for each case, in which case the
614
614
commas are optional.
@@ -865,7 +865,7 @@ fn area(sh: Shape) -> float {
865
865
}
866
866
~~~~
867
867
868
- You can write a lone ` _ ` to ignore an individual fields , and can
868
+ You can write a lone ` _ ` to ignore an individual field , and can
869
869
ignore all fields of a variant like: ` Circle(*) ` . As in their
870
870
introduction form, nullary enum patterns are written without
871
871
parentheses.
@@ -1096,7 +1096,7 @@ All pointer types can be dereferenced with the `*` unary operator.
1096
1096
Managed boxes are pointers to heap-allocated, garbage collected
1097
1097
memory. Applying the unary ` @ ` operator to an expression creates a
1098
1098
managed box. The resulting box contains the result of the
1099
- expression. Copying a shared box, as happens during assignment, only
1099
+ expression. Copying a managed box, as happens during assignment, only
1100
1100
copies a pointer, never the contents of the box.
1101
1101
1102
1102
~~~~
@@ -1145,7 +1145,7 @@ Managed boxes never cross task boundaries.
1145
1145
In contrast with managed boxes, owned boxes have a single owning
1146
1146
memory slot and thus two owned boxes may not refer to the same
1147
1147
memory. All owned boxes across all tasks are allocated on a single
1148
- _ exchange heap_ , where their uniquely owned nature allows tasks to
1148
+ _ exchange heap_ , where their uniquely- owned nature allows tasks to
1149
1149
exchange them efficiently.
1150
1150
1151
1151
Because owned boxes are uniquely owned, copying them requires allocating
@@ -1158,7 +1158,7 @@ let x = ~10;
1158
1158
let y = x; // error: copying a non-implicitly copyable type
1159
1159
~~~~
1160
1160
1161
- If you really want to copy a unique box you must say so explicitly.
1161
+ If you really want to copy an owned box you must say so explicitly.
1162
1162
1163
1163
~~~~
1164
1164
let x = ~10;
@@ -1190,7 +1190,7 @@ become the sole owner of the box.
1190
1190
1191
1191
Rust borrowed pointers are a general purpose reference/pointer type,
1192
1192
similar to the C++ reference type, but guaranteed to point to valid
1193
- memory. In contrast with owned pointers, where the holder of a unique
1193
+ memory. In contrast with owned pointers, where the holder of an owned
1194
1194
pointer is the owner of the pointed-to memory, borrowed pointers never
1195
1195
imply ownership. Pointers may be borrowed from any type, in which case
1196
1196
the pointer is guaranteed not to outlive the value it points to.
@@ -1210,14 +1210,14 @@ contains a point, but allocated in a different location:
1210
1210
~~~
1211
1211
# struct Point { x: float, y: float }
1212
1212
let on_the_stack : Point = Point {x: 3.0, y: 4.0};
1213
- let shared_box : @Point = @Point {x: 5.0, y: 1.0};
1214
- let unique_box : ~ Point = ~ Point {x: 7.0, y: 9.0};
1213
+ let managed_box : @Point = @Point {x: 5.0, y: 1.0};
1214
+ let owned_box : ~ Point = ~ Point {x: 7.0, y: 9.0};
1215
1215
~~~
1216
1216
1217
1217
Suppose we wanted to write a procedure that computed the distance
1218
1218
between any two points, no matter where they were stored. For example,
1219
1219
we might like to compute the distance between `on_the_stack` and
1220
- `shared_box `, or between `shared_box ` and `unique_box `. One option is
1220
+ `managed_box `, or between `managed_box ` and `owned_box `. One option is
1221
1221
to define a function that takes two arguments of type point—that is,
1222
1222
it takes the points by value. But this will cause the points to be
1223
1223
copied when we call the function. For points, this is probably not so
@@ -1241,11 +1241,11 @@ Now we can call `compute_distance()` in various ways:
1241
1241
~~~
1242
1242
# struct Point{ x: float, y: float };
1243
1243
# let on_the_stack : Point = Point {x: 3.0, y: 4.0};
1244
- # let shared_box : @Point = @Point {x: 5.0, y: 1.0};
1245
- # let unique_box : ~ Point = ~ Point {x: 7.0, y: 9.0};
1244
+ # let managed_box : @Point = @Point {x: 5.0, y: 1.0};
1245
+ # let owned_box : ~ Point = ~ Point {x: 7.0, y: 9.0};
1246
1246
# fn compute_distance(p1: &Point, p2: &Point) -> float { 0f }
1247
- compute_distance(&on_the_stack, shared_box );
1248
- compute_distance(shared_box, unique_box );
1247
+ compute_distance(&on_the_stack, managed_box );
1248
+ compute_distance(managed_box, owned_box );
1249
1249
~~~
1250
1250
1251
1251
Here the `&` operator is used to take the address of the variable
@@ -1255,11 +1255,11 @@ value. We also call this _borrowing_ the local variable
1255
1255
`on_the_stack`, because we are created an alias: that is, another
1256
1256
route to the same data.
1257
1257
1258
- In the case of the boxes `shared_box ` and `unique_box `, however, no
1258
+ In the case of the boxes `managed_box ` and `owned_box `, however, no
1259
1259
explicit action is necessary. The compiler will automatically convert
1260
1260
a box like `@point` or `~point` to a borrowed pointer like
1261
1261
`&point`. This is another form of borrowing; in this case, the
1262
- contents of the shared/unique box is being lent out.
1262
+ contents of the managed/owned box is being lent out.
1263
1263
1264
1264
Whenever a value is borrowed, there are some limitations on what you
1265
1265
can do with the original. For example, if the contents of a variable
0 commit comments