@@ -8,9 +8,7 @@ This is a tutorial for the Rust programming language. It assumes the
8
8
reader is familiar with the basic concepts of programming, and has
9
9
programmed in one or more other languages before. The tutorial covers
10
10
the whole language, though not with the depth and precision of the
11
- [ language reference] [ 1 ] .
12
-
13
- [ 1 ] : http://www.rust-lang.org/doc/rust.html
11
+ [ language reference] ( rust.html ) .
14
12
15
13
## Disclaimer
16
14
@@ -106,7 +104,7 @@ live inside a function.
106
104
Rust programs can also be compiled as libraries, and included in other
107
105
programs. The ` use std ` directive that appears at the top of a lot of
108
106
examples imports the [ standard library] [ std ] . This is described in more
109
- detail [ later on] ( mod.html ) .
107
+ detail [ later on] ( #modules-and-crates ) .
110
108
111
109
[ std ] : http://doc.rust-lang.org/doc/std/index/General.html
112
110
@@ -332,10 +330,9 @@ type monster_size = uint;
332
330
This will provide a synonym, ` monster_size ` , for unsigned integers. It
333
331
will not actually create a new type—` monster_size ` and ` uint ` can be
334
332
used interchangeably, and using one where the other is expected is not
335
- a type error. Read about [ single-variant enums] [ sve ] further on if you
336
- need to create a type name that's not just a synonym.
337
-
338
- [ sve ] : data.html#single_variant_enum
333
+ a type error. Read about [ single-variant enums] ( #single_variant_enum )
334
+ further on if you need to create a type name that's not just a
335
+ synonym.
339
336
340
337
## Literals
341
338
@@ -435,8 +432,6 @@ assert y == 4u;
435
432
436
433
## Attributes
437
434
438
- <a name =" conditional " ></a >
439
-
440
435
Every definition can be annotated with attributes. Attributes are meta
441
436
information that can serve a variety of purposes. One of those is
442
437
conditional compilation:
@@ -457,12 +452,12 @@ Attributes are always wrapped in hash-braces (`#[attr]`). Inside the
457
452
braces, a small minilanguage is supported, whose interpretation
458
453
depends on the attribute that's being used. The simplest form is a
459
454
plain name (as in ` #[test] ` , which is used by the [ built-in test
460
- framework] ( test.html ' ' ) ). A name-value pair can be provided using an ` = `
455
+ framework] ( #testing ) ). A name-value pair can be provided using an ` = `
461
456
character followed by a literal (as in ` #[license = "BSD"] ` , which is
462
457
a valid way to annotate a Rust program as being released under a
463
458
BSD-style license). Finally, you can have a name followed by a
464
459
comma-separated list of nested attributes, as in the ` cfg ` example
465
- above, or in this [ crate] ( mod.html ) metadata declaration:
460
+ above, or in this [ crate] ( #modules-and-crates ) metadata declaration:
466
461
467
462
~~~~
468
463
## ignore
@@ -662,7 +657,7 @@ moment.
662
657
663
658
## Failure
664
659
665
- The ` fail ` keyword causes the current [ task] [ tasks ] to fail. You use
660
+ The ` fail ` keyword causes the current [ task] ( # tasks) to fail. You use
666
661
it to indicate unexpected failure, much like you'd use ` exit(1) ` in a
667
662
C program, except that in Rust, it is possible for other tasks to
668
663
handle the failure, allowing the program to continue running.
@@ -671,8 +666,6 @@ handle the failure, allowing the program to continue running.
671
666
to access a vector out of bounds, or running a pattern match with no
672
667
matching clauses, both result in the equivalent of a ` fail ` .
673
668
674
- [ tasks ] : task.html
675
-
676
669
## Logging
677
670
678
671
Rust has a built-in logging mechanism, using the ` log ` statement.
@@ -835,14 +828,12 @@ call_twice(bare_function);
835
828
836
829
### Unique closures
837
830
838
- <a name =" unique " ></a >
839
-
840
831
Unique closures, written ` fn~ ` in analogy to the ` ~ ` pointer type (see
841
832
next section), hold on to things that can safely be sent between
842
833
processes. They copy the values they close over, much like boxed
843
834
closures, but they also 'own' them—meaning no other code can access
844
835
them. Unique closures mostly exist to for spawning new
845
- [ tasks] ( task.html ) .
836
+ [ tasks] ( #tasks ) .
846
837
847
838
### Shorthand syntax
848
839
@@ -1151,8 +1142,6 @@ All pointer types can be dereferenced with the `*` unary operator.
1151
1142
1152
1143
### Shared boxes
1153
1144
1154
- <a name =" shared-box " ></a >
1155
-
1156
1145
Shared boxes are pointers to heap-allocated, reference counted memory.
1157
1146
A cycle collector ensures that circular references do not result in
1158
1147
memory leaks.
@@ -1174,8 +1163,6 @@ Shared boxes never cross task boundaries.
1174
1163
1175
1164
### Unique boxes
1176
1165
1177
- <a name =" unique-box " ></a >
1178
-
1179
1166
In contrast to shared boxes, unique boxes are not reference counted.
1180
1167
Instead, it is statically guaranteed that only a single owner of the
1181
1168
box exists at any time.
@@ -1414,7 +1401,7 @@ records and tags *are* passed by pointer, but single-word values, like
1414
1401
integers and pointers, are simply passed by value. Most of the time,
1415
1402
the programmer does not have to worry about this, as the compiler will
1416
1403
simply pick the most efficient passing style. There is one exception,
1417
- which will be described in the section on [ generics] ( generic.html ) .
1404
+ which will be described in the section on [ generics] ( #generics ) .
1418
1405
1419
1406
To explicitly set the passing-style for a parameter, you prefix the
1420
1407
argument name with a sigil. There are two special passing styles that
@@ -1542,8 +1529,6 @@ without any sophistication).
1542
1529
1543
1530
## Kinds
1544
1531
1545
- <a name =" kind " ></a >
1546
-
1547
1532
Perhaps surprisingly, the 'copy' (duplicate) operation is not defined
1548
1533
for all Rust types. Resource types (types with destructors) can not be
1549
1534
copied, and neither can any type whose copying would require copying a
@@ -1724,7 +1709,7 @@ A set of basic library routines, mostly related to built-in datatypes
1724
1709
and the task system, are always implicitly linked and included in any
1725
1710
Rust program, unless the ` --no-core ` compiler switch is given.
1726
1711
1727
- This library is document [ here] [ core ] .
1712
+ This library is documented [ here] [ core ] .
1728
1713
1729
1714
[ core ] : http://doc.rust-lang.org/doc/core/index/General.html
1730
1715
@@ -2310,11 +2295,9 @@ supposed to point at, this is safe.
2310
2295
Rust supports a system of lightweight tasks, similar to what is found
2311
2296
in Erlang or other actor systems. Rust tasks communicate via messages
2312
2297
and do not share data. However, it is possible to send data without
2313
- copying it by making use of [ unique boxes] [ uniques ] , which allow the
2314
- sending task to release ownership of a value, so that the receiving
2315
- task can keep on using it.
2316
-
2317
- [ uniques ] : data.html#unique-box
2298
+ copying it by making use of [ unique boxes] ( #unique-boxes ) , which allow
2299
+ the sending task to release ownership of a value, so that the
2300
+ receiving task can keep on using it.
2318
2301
2319
2302
NOTE: As Rust evolves, we expect the Task API to grow and change
2320
2303
somewhat. The tutorial documents the API as it exists today.
@@ -2333,7 +2316,7 @@ let child_task = task::spawn {||
2333
2316
~~~~
2334
2317
2335
2318
The argument to ` task::spawn() ` is a [ unique
2336
- closure] ( func.html #unique) of type ` fn~() ` , meaning that it takes no
2319
+ closure] ( #unique-closures ) of type ` fn~() ` , meaning that it takes no
2337
2320
arguments and generates no return value. The effect of ` task::spawn() `
2338
2321
is to fire up a child task that will execute the closure in parallel
2339
2322
with the creator. The result is a task id, here stored into the
@@ -2553,4 +2536,4 @@ ignored.
2553
2536
A program compiled as a test runner will have the configuration flag
2554
2537
` test ` defined, so that you can add code that won't be included in a
2555
2538
normal compile with the ` #[cfg(test)] ` attribute (see [ conditional
2556
- compilation] ( syntax.md#conditional ) ).
2539
+ compilation] ( #attributes ) ).
0 commit comments