Skip to content

Commit befd70d

Browse files
committed
---
yaml --- r: 32758 b: refs/heads/dist-snap c: c2bc512 h: refs/heads/master v: v3
1 parent 3ad3e20 commit befd70d

File tree

2 files changed

+34
-61
lines changed

2 files changed

+34
-61
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: d0c6ce338884ee21843f4b40bf6bf18d222ce5df
99
refs/heads/incoming: d9317a174e434d4c99fc1a37fd7dc0d2f5328d37
10-
refs/heads/dist-snap: fd0de8bfd70b01dd01ca541bfdfb52703fa44d9c
10+
refs/heads/dist-snap: c2bc5122cd2122edcc0a4fd23288b19378ad2d3a
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/dist-snap/doc/tutorial.md

Lines changed: 33 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -2,79 +2,52 @@
22

33
# Introduction
44

5-
## Scope
6-
7-
This is a tutorial for the Rust programming language. It assumes the
8-
reader is familiar with the basic concepts of programming, and has
9-
programmed in one or more other languages before. It will often make
10-
comparisons to other languages in the C family. This tutorial covers
11-
the fundamentals of the language, including the syntax, the type
12-
system and memory model, and generics.
13-
[Additional tutorials](#what-next) cover specific language features in
14-
greater depth.
15-
16-
## Language overview
17-
18-
Rust is a systems programming language with a focus on type safety,
19-
memory safety, concurrency and performance. It is intended for writing
20-
large, high-performance applications while preventing several classes
21-
of errors commonly found in languages like C++. Rust has a
22-
sophisticated memory model that makes possible many of the efficient
23-
data structures used in C++, while disallowing invalid memory accesses
24-
that would otherwise cause segmentation faults. Like other systems
25-
languages, it is statically typed and compiled ahead of time.
5+
Rust is a programming language with a focus on type safety, memory
6+
safety, concurrency and performance. It is intended for writing
7+
large-scale, high-performance software while preventing several
8+
classes of common errors. Rust has a sophisticated memory model that
9+
encourages efficient data structures and safe concurrency patterns,
10+
forbidding invalid memory accesses that would otherwise cause
11+
segmentation faults. It is statically typed and compiled ahead of
12+
time.
2613

2714
As a multi-paradigm language, Rust supports writing code in
28-
procedural, functional and object-oriented styles. Some of its nice
29-
high-level features include:
15+
procedural, functional and object-oriented styles. Some of its
16+
pleasant high-level features include:
3017

31-
* **Pattern matching and algebraic data types (enums).** Common in
32-
functional languages, pattern matching on ADTs provides a compact
33-
and expressive way to encode program logic.
18+
* **Pattern matching and algebraic data types (enums).** As
19+
popularized by functional languages, pattern matching on ADTs
20+
provides a compact and expressive way to encode program logic.
21+
* **Type inference.** Type annotations on local variable
22+
declarations are optional.
3423
* **Task-based concurrency.** Rust uses lightweight tasks that do
3524
not share memory.
36-
* **Higher-order functions.** Rust functions may take closures as
37-
arguments or return closures as return values. Closures in Rust are
38-
very powerful and used pervasively.
39-
* **Trait polymorphism.** Rust's type system features a unique
40-
combination of Java-style interfaces and Haskell-style typeclasses
41-
called _traits_.
25+
* **Higher-order functions.** Rust's efficient and flexible closures
26+
are heavily relied on to provide iteration and other control
27+
structures
4228
* **Parametric polymorphism (generics).** Functions and types can be
43-
parameterized over type variables with optional type constraints.
44-
* **Type inference.** Type annotations on local variable
45-
declarations can be omitted.
46-
47-
## First impressions
48-
49-
As a curly-brace language in the tradition of C, C++, and JavaScript,
50-
Rust looks a lot like other languages you may be familiar with.
29+
parameterized over type variables with optional trait-based type
30+
constraints.
31+
* **Trait polymorphism.** Rust's type system features a unique
32+
combination of type classes and object-oriented interfaces.
5133

52-
~~~~
53-
fn boring_old_factorial(n: int) -> int {
54-
let mut result = 1, i = 1;
55-
while i <= n {
56-
result *= i;
57-
i += 1;
58-
}
59-
return result;
60-
}
61-
~~~~
34+
## Scope
6235

63-
Several differences from C stand out. Types do not come before, but
64-
after variable names (preceded by a colon). For local variables
65-
(introduced with `let`), types are optional, and will be inferred when
66-
left off. Constructs like `while` and `if` do not require parentheses
67-
around the condition (though they allow them).
36+
This is an introductory tutorial for the Rust programming language. It
37+
covers the fundamentals of the language, including the syntax, the
38+
type system and memory model, and generics. [Additional
39+
tutorials](#what-next) cover specific language features in greater
40+
depth.
6841

69-
You should, however, not conclude that Rust is simply an evolution of
70-
C. As will become clear in the rest of this tutorial, it goes in quite
71-
a different direction, with efficient, strongly-typed and memory-safe
72-
support for many high-level idioms.
42+
It assumes the reader is familiar with the basic concepts of
43+
programming, and has programmed in one or more other languages
44+
before. It will often make comparisons to other languages,
45+
particularly those in the C family.
7346

7447
## Conventions
7548

7649
Throughout the tutorial, words that indicate language keywords or
77-
identifiers defined in the example code are displayed in `code font`.
50+
identifiers defined in example code are displayed in `code font`.
7851

7952
Code snippets are indented, and also shown in a monospaced font. Not
8053
all snippets constitute whole programs. For brevity, we'll often show

0 commit comments

Comments
 (0)