@-ify part 01; update main for non-Linux users
[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 sacrificies 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 race conditions.
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/). You should go for either the "stable"
40 // or the "beta" channel. More detailed installation instructions are provided in
41 // [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 [zip archive](https://github.com/RalfJung/rust-101/archive/master.zip)).
46 // There is a workspace prepared for you in the `workspace` folder. I suggest you copy this
47 // folder somewhere else - that will make it much easier to later update the course without
48 // overwriting your changes. Try `cargo build` in that new folder to check that compiling your workspace succeeds.
49 // (You can also execute it with `cargo run`, but you'll need to do some work before this will succeed.)
50 // 
51 // If you later want to update the course, do `git pull` (or re-download the tip archive).
52 // Then copy the files from `workspace/src/` to your workspace that you did not yet work on. (Of course you can also
53 // copy the rest, but that would replace all your hard work by the original files with all the holes!)
54
55 // Course Content
56 // --------------
57 // 
58 // The part 00-03 cover some basic of the language, to give you a feeling for Rust's syntax and pervasive
59 // mechanisms like pattern matching and traits. Parts 04-06 introduce the heart of the language, the ideas
60 // making it different from anything else out there: Ownership, borrowing, lifetimes. In part 07-??, we
61 // continue our tour through Rust with another example. Finally, in parts ??-??, we implement our own
62 // version of `grep`, exhibiting some more Rust features as we go.
63 // 
64 // Now, open `your-workspace/src/part00.rs` in your favorite editor, and follow the link below for
65 // the explanations and exercises. Have fun!
66 // 
67 // * [Part 00: Algebraic datatypes](part00.html)
68 // * [Part 01: Expressions, Inherent methods](part01.html)
69 // * [Part 02: Generic types, Traits](part02.html)
70 // * [Part 03: Input](part03.html)
71 // * [Part 04: Ownership, Borrowing](part04.html)
72 // * [Part 05: Clone](part05.html)
73 // * [Part 06: Copy, Lifetimes](part06.html)
74 // * [Part 07: Operator Overloading, Tests, Formating](part07.html)
75 // * (to be continued)
76 #![allow(dead_code, unused_imports, unused_variables, unused_mut)]
77 mod part00;
78 mod part01;
79 mod part02;
80 mod part03;
81 mod part04;
82 mod part05;
83 mod part06;
84 mod part07;
85 mod part08;
86 mod part09;
87
88 // To actually run the code of some part (after filling in the blanks, if necessary), simply edit the `main`
89 // function.
90
91 fn main() {
92     part00::main();
93 }
94
95 // Additional material
96 // -------------------
97 // 
98 // There's tons of useful Rust stuff out there, so let me just put links to some
99 // of the most interesting places here:
100 // 
101 // * [The Rust Book](https://doc.rust-lang.org/stable/book/)
102 // * [Rust by Example](http://rustbyexample.com/)
103 // * The [Rust Subreddit](https://www.reddit.com/r/rust/)
104 // * For the IRC channel and other forums, see the "Community" section of the [Rust Documentation index](http://doc.rust-lang.org/index.html)