4
4
5
5
Rust is a programming language with a focus on type safety, memory
6
6
safety, concurrency and performance. It is intended for writing
7
- large-scale, high-performance software while preventing several
7
+ large-scale, high-performance software that is free from several
8
8
classes of common errors. Rust has a sophisticated memory model that
9
9
encourages efficient data structures and safe concurrency patterns,
10
10
forbidding invalid memory accesses that would otherwise cause
@@ -18,13 +18,14 @@ pleasant high-level features include:
18
18
* ** Type inference.** Type annotations on local variable declarations
19
19
are optional.
20
20
* ** Safe task-based concurrency.** Rust's lightweight tasks do not share
21
- memory and communicate through messages.
21
+ memory, instead communicating through messages.
22
22
* ** Higher-order functions.** Efficient and flexible closures provide
23
23
iteration and other control structures
24
24
* ** Pattern matching and algebraic data types.** Pattern matching on
25
- Rust's enums is a compact and expressive way to encode program
26
- logic.
27
- * ** Polymorphism.** Rust has type-parameric functions and
25
+ Rust's enumeration types (a more powerful version of C's enums,
26
+ similar to algebraic data types in functional languages) is a
27
+ compact and expressive way to encode program logic.
28
+ * ** Polymorphism.** Rust has type-parametric functions and
28
29
types, type classes and OO-style interfaces.
29
30
30
31
## Scope
@@ -35,23 +36,23 @@ type system and memory model, generics, and modules. [Additional
35
36
tutorials] ( #what-next ) cover specific language features in greater
36
37
depth.
37
38
38
- It assumes the reader is familiar with the basic concepts of
39
+ This tutorial assumes that the reader is familiar with the basic concepts of
39
40
programming, and has programmed in one or more other languages
40
- before. It will often make comparisons to other languages,
41
+ before. We will often compare Rust to other languages,
41
42
particularly those in the C family.
42
43
43
44
## Conventions
44
45
45
- Throughout the tutorial, words that indicate language keywords or
46
- identifiers defined in example code are displayed in ` code font ` .
46
+ Throughout the tutorial, language keywords and identifiers defined in
47
+ example code are displayed in ` code font ` .
47
48
48
49
Code snippets are indented, and also shown in a monospaced font. Not
49
50
all snippets constitute whole programs. For brevity, we'll often show
50
51
fragments of programs that don't compile on their own. To try them
51
52
out, you might have to wrap them in ` fn main() { ... } ` , and make sure
52
- they don't contain references to things that aren't actually defined.
53
+ they don't contain references to names that aren't actually defined.
53
54
54
- > *** Warning:*** Rust is a language under heavy development. Notes
55
+ > *** Warning:*** Rust is a language under ongoing development. Notes
55
56
> about potential changes to the language, implementation
56
57
> deficiencies, and other caveats appear offset in blockquotes.
57
58
@@ -77,9 +78,14 @@ You may find that other platforms work, but these are our "tier 1"
77
78
supported build environments that are most likely to work.
78
79
79
80
> *** Note:*** Windows users should read the detailed
80
- > [ getting started] [ wiki-start ] notes on the wiki. Even when using
81
- > the binary installer the Windows build requires a MinGW installation,
82
- > the precise details of which are not discussed here.
81
+ > "[ getting started] [ wiki-start ] " notes on the wiki. Even when using
82
+ > the binary installer, the Windows build requires a MinGW installation,
83
+ > the precise details of which are not discussed here. Finally, ` rustc ` may
84
+ > need to be [ referred to as ` rustc.exe ` ] [ bug-3319 ] . It's a bummer, I
85
+ > know.
86
+
87
+ [ bug-3319 ] : https://github.com/mozilla/rust/issues/3319
88
+ [ wiki-start ] : https://github.com/mozilla/rust/wiki/Note-getting-started-developing-Rust
83
89
84
90
To build from source you will also need the following prerequisite
85
91
packages:
@@ -90,8 +96,8 @@ packages:
90
96
* gnu make 3.81 or later
91
97
* curl
92
98
93
- Assuming you're on a relatively modern * nix system and have met the
94
- prerequisites, something along these lines should work.
99
+ If you've fulfilled those prerequisites, something along these lines
100
+ should work.
95
101
96
102
~~~~ {.notrust}
97
103
$ wget http://dl.rust-lang.org/dist/rust-0.4.tar.gz
@@ -104,7 +110,7 @@ $ make && make install
104
110
You may need to use ` sudo make install ` if you do not normally have
105
111
permission to modify the destination directory. The install locations
106
112
can be adjusted by passing a ` --prefix ` argument to
107
- ` configure ` . Various other options are also supported, pass ` --help `
113
+ ` configure ` . Various other options are also supported: pass ` --help `
108
114
for more information on them.
109
115
110
116
When complete, ` make install ` will place several programs into
@@ -130,10 +136,10 @@ If the Rust compiler was installed successfully, running `rustc
130
136
hello.rs` will produce an executable called ` hello` (or ` hello.exe` on
131
137
Windows) which, upon running, will likely do exactly what you expect.
132
138
133
- The Rust compiler tries to provide useful information when it runs
134
- into an error. If you modify the program to make it invalid (for
135
- example, by changing ` io::println ` to some nonexistent function), and
136
- then compile it, you'll see an error message like this:
139
+ The Rust compiler tries to provide useful information when it encounters an
140
+ error. If you introduce an error into the program (for example, by changing
141
+ ` io::println ` to some nonexistent function), and then compile it, you'll see
142
+ an error message like this:
137
143
138
144
~~~~ {.notrust}
139
145
hello.rs:2:4: 2:16 error: unresolved name: io::print_with_unicorns
@@ -144,19 +150,10 @@ hello.rs:2 io::print_with_unicorns("hello? yes, this is rust");
144
150
In its simplest form, a Rust program is a ` .rs ` file with some types
145
151
and functions defined in it. If it has a ` main ` function, it can be
146
152
compiled to an executable. Rust does not allow code that's not a
147
- declaration to appear at the top level of the file— all statements must
153
+ declaration to appear at the top level of the file: all statements must
148
154
live inside a function. Rust programs can also be compiled as
149
155
libraries, and included in other programs.
150
156
151
- > *** Note:*** There are some 'gotchas' to be aware of on
152
- > Windows. First, the MinGW environment must be set up
153
- > perfectly. Please read [ the wiki] [ wiki-started ] . Second, ` rustc ` may
154
- > need to be [ referred to as ` rustc.exe ` ] [ bug-3319 ] . It's a bummer, I
155
- > know.
156
-
157
- [ bug-3319 ] : https://github.com/mozilla/rust/issues/3319
158
- [ wiki-started ] : https://github.com/mozilla/rust/wiki/Note-getting-started-developing-Rust
159
-
160
157
## Editing Rust code
161
158
162
159
There are vim highlighting and indentation scripts in the Rust source
@@ -170,7 +167,7 @@ Sublime Text 2, available both [standalone][sublime] and through
170
167
under ` src/etc/kate ` .
171
168
172
169
There is ctags support via ` src/etc/ctags.rust ` , but many other
173
- tools and editors are not provided for yet. If you end up writing a Rust
170
+ tools and editors are not yet supported . If you end up writing a Rust
174
171
mode for your favorite editor, let us know so that we can link to it.
175
172
176
173
[ sublime ] : http://github.com/dbp/sublime-rust
0 commit comments