@@ -872,17 +872,6 @@ is optionally followed by an expression to return. A function can
872
872
also return a value by having its top level block produce an
873
873
expression.
874
874
875
- ~~~~
876
- # const copernicus: int = 0;
877
- fn int_to_str(i: int) -> ~str {
878
- if i == copernicus {
879
- return ~"tube sock";
880
- } else {
881
- return ~"violin";
882
- }
883
- }
884
- ~~~~
885
-
886
875
~~~~
887
876
fn line(a: int, b: int, x: int) -> int {
888
877
a*x + b
@@ -1122,7 +1111,7 @@ let x = ~10;
1122
1111
let y = copy x;
1123
1112
1124
1113
let z = *x + *y;
1125
- assert z = 20;
1114
+ assert z == 20;
1126
1115
~~~~
1127
1116
1128
1117
This is where the 'move' operator comes in. It is similar to
@@ -1131,7 +1120,7 @@ from `x` to `y`, without violating the constraint that it only has a
1131
1120
single owner (if you used assignment instead of the move operator, the
1132
1121
box would, in principle, be copied).
1133
1122
1134
- ~~~~ {.ignore }
1123
+ ~~~~ {.xfail-test }
1135
1124
let x = ~10;
1136
1125
let y = move x;
1137
1126
@@ -1273,7 +1262,7 @@ also done with square brackets (zero-based):
1273
1262
# BananaMania, Beaver, Bittersweet };
1274
1263
# fn draw_scene(c: Crayon) { }
1275
1264
1276
- let crayons: [Crayon] = [BananaMania, Beaver, Bittersweet];
1265
+ let crayons: [Crayon * 3 ] = [BananaMania, Beaver, Bittersweet];
1277
1266
match crayons[0] {
1278
1267
Bittersweet => draw_scene(crayons[0]),
1279
1268
_ => ()
@@ -1290,7 +1279,7 @@ elements. Mutable vector literals are written `[mut]` (empty) or `[mut
1290
1279
# Aquamarine, Asparagus, AtomicTangerine,
1291
1280
# BananaMania, Beaver, Bittersweet };
1292
1281
1293
- let crayons: [mut Crayon] = [mut BananaMania, Beaver, Bittersweet];
1282
+ let crayons: [mut Crayon * 3 ] = [mut BananaMania, Beaver, Bittersweet];
1294
1283
crayons[0] = AtomicTangerine;
1295
1284
~~~~
1296
1285
@@ -1330,7 +1319,8 @@ Strings are implemented with vectors of `[u8]`, though they have a distinct
1330
1319
type. They support most of the same allocation options as
1331
1320
vectors, though the string literal without a storage sigil, e.g.
1332
1321
`"foo"` is treated differently than a comparable vector (`[foo]`).
1333
- Where
1322
+ Wheras plain vectors are stack-allocated fixed length vectors,
1323
+ plain strings are region pointers to read-only memory.
1334
1324
1335
1325
~~~
1336
1326
// A plain string is a slice to read-only (static) memory
0 commit comments