19abe4eacfd1ccef31fff28b0979698f9cff1a98
[rust-101.git] / src / main.rs
1 // Welcome to Rust-101
2 // ===================
3 // 
4 // This is [Rust-101](https://www.ralfj.de/projects/rust-101/), a small *work-in-progress*
5 // tutorial for the [Rust language](http://www.rust-lang.org/).
6 // It is intended to be an interactive, hands-on course: I believe the only way to
7 // *really* learn a language is to write code in it, so you should be coding during
8 // the course.
9 // 
10 // If you have any questions that are not answered here, check out the "Additional Resources"
11 // below. In particular, the IRC channel is filled with awesome people willing to help you! I spent
12 // lots of time there ;-)
13 // 
14 // I will assume some familiarity with programming, and hence not explain the basic
15 // concepts common to most languages. Instead, I will focus on what makes Rust special.
16 //
17 // Why Rust?
18 // ---------
19 // 
20 // When you got here, I am kind of assuming that you already decided to give Rust at
21 // least a look, so that I don't have to do much convincing here ;-) . But just in
22 // case, here's why I think Rust is worth learning:<br/>
23 // At this time, Rust is a language with a pretty unique set of goals. Rust aims to
24 // achieve C++-style control over memory and execution behavior (like, static vs. dynamic
25 // dispatch), which makes it possible to construct abstractions that carry no run-time
26 // cost. This is combined with the comfort of high-level functional languages and guaranteed
27 // safety (as in, the program will not crash). The vast majority of existing
28 // languages sacrifices one of these goals for the other. In particular, the
29 // first requirement rules out a garbage collector: Rust can run "bare metal".
30 // In fact, Rust rules out more classes of bugs than languages that achieve safety
31 // with a GC: Besides dangling pointers and double-free, Rust also prevents issues
32 // such as iterator invalidation and data races.
33 // 
34 // 
35 // Getting started
36 // ---------------
37 // 
38 // You will need to have Rust installed, of course. It is available for download on
39 // [the Rust website](http://www.rust-lang.org/). Make sure you get at least version 1.2
40 // (at the time of writing, that's the current beta release). More detailed installation
41 // instructions are provided in [the second chapter of The Book](https://doc.rust-lang.org/stable/book/installing-rust.html).
42 // This will also install `cargo`, the tool responsible for building rust projects (or *crates*).
43
44 // Next, fetch the Rust-101 source code from the [git repository](http://www.ralfj.de/git/rust-101.git)
45 // (also available [on GitHub](https://github.com/RalfJung/rust-101), and as a
46 // [zip archive](https://github.com/RalfJung/rust-101/archive/master.zip) in case you don't have git installed).
47 // 
48 // There is a workspace prepared for you in the `workspace` folder. I suggest you copy this
49 // folder somewhere else - that will make it much easier to later update the course without
50 // overwriting your changes. Try `cargo build` in that new folder to check that compiling your workspace succeeds.
51 // (You can also execute it with `cargo run`, but you'll need to do some work before this will succeed.)
52 // 
53 // If you later want to update the course, do `git pull` (or re-download the zip archive).
54 // Then copy the files from `workspace/src/` to your workspace that you did not yet work on. Definitely
55 // copy `main.rs` to make sure all the new files are actually compiled. (Of course you can also
56 // copy the rest, but that would replace all your hard work by the original files with all the holes!)
57
58 // Course Content
59 // --------------
60 // 
61 // Open `your-workspace/src/part00.rs` in your favorite editor, and follow the link below for
62 // the explanations and exercises. Have fun!
63 // 
64 // ### Introduction
65 //
66 // * [Part 00: Algebraic datatypes](part00.html)
67 // * [Part 01: Expressions, Inherent methods](part01.html)
68 // * [Part 02: Generic types, Traits](part02.html)
69 // * [Part 03: Input](part03.html)
70 // 
71 // ### Basic Rust
72 // 
73 // * [Part 04: Ownership, Borrowing](part04.html)
74 // * [Part 05: Clone](part05.html)
75 // * [Part 06: Copy, Lifetimes](part06.html)
76 // * [Part 07: Operator Overloading, Tests, Formating](part07.html)
77 // * [Part 08: Associated Types, Modules](part08.html)
78 // * [Part 09: Iterators](part09.html)
79 // * [Part 10: Closures](part10.html)
80 // 
81 // ### Advanced Rust
82 // 
83 // * [Part 11: Trait Objects, Box, Lifetime bounds](part11.html)
84 // * [Part 12: Rc, Interior Mutability, Cell, RefCell](part12.html)
85 // * [Part 13: Concurrency, Arc, Send](part13.html)
86 // * [Part 14: Slices, Arrays, External Dependencies](part14.html)
87 // * [Part 15: Mutex, Interior Mutability (cont.), RwLock, Sync](part15.html)
88 // * (to be continued)
89 // 
90 #![allow(dead_code, unused_imports, unused_variables, unused_mut, unreachable_code)]
91 mod part00;
92 mod part01;
93 mod part02;
94 mod part03;
95 mod part04;
96 mod part05;
97 mod part06;
98 mod part07;
99 mod part08;
100 mod part09;
101 mod part10;
102 mod part11;
103 mod part12;
104 mod part13;
105 mod part14;
106 mod part15;
107 mod part16;
108
109 // To actually run the code of some part (after filling in the blanks, if necessary), simply edit the `main`
110 // function.
111 fn main() {
112     part00::main();
113 }
114
115
116 // Additional material
117 // -------------------
118 // 
119 // There's tons of useful Rust stuff out there, so let me just put links to some
120 // of the most interesting places here:
121 // 
122 // * [The Rust Book](https://doc.rust-lang.org/stable/book/)
123 // * [Rust by Example](http://rustbyexample.com/)
124 // * The [Rust Subreddit](https://www.reddit.com/r/rust/)
125 // * For the IRC channel and other forums, see the "Community" section of the [Rust Documentation index](http://doc.rust-lang.org/index.html)