*oops*
[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 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 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 // The part 00-03 cover some basic of the language, to give you a feeling for Rust's syntax and pervasive
62 // mechanisms like pattern matching and traits. Parts 04-06 introduce the heart of the language, the ideas
63 // making it different from anything else out there: Ownership, borrowing, lifetimes. In part 07-??, we
64 // continue our tour through Rust with another example. Finally, in parts ??-??, we implement our own
65 // version of `grep`, exhibiting some more Rust features as we go.
66 // 
67 // Now, open `your-workspace/src/part00.rs` in your favorite editor, and follow the link below for
68 // the explanations and exercises. Have fun!
69 // 
70 // * [Part 00: Algebraic datatypes](part00.html)
71 // * [Part 01: Expressions, Inherent methods](part01.html)
72 // * [Part 02: Generic types, Traits](part02.html)
73 // * [Part 03: Input](part03.html)
74 // * [Part 04: Ownership, Borrowing](part04.html)
75 // * [Part 05: Clone](part05.html)
76 // * [Part 06: Copy, Lifetimes](part06.html)
77 // * [Part 07: Operator Overloading, Tests, Formating](part07.html)
78 // * [Part 08: Associated Types, Modules](part08.html)
79 // * (to be continued)
80 #![allow(dead_code, unused_imports, unused_variables, unused_mut)]
81 mod part00;
82 mod part01;
83 mod part02;
84 mod part03;
85 mod part04;
86 mod part05;
87 mod part06;
88 mod part07;
89 mod part08;
90 mod part09;
91
92 // To actually run the code of some part (after filling in the blanks, if necessary), simply edit the `main`
93 // function.
94
95 fn main() {
96     part00::main();
97 }
98
99 // Additional material
100 // -------------------
101 // 
102 // There's tons of useful Rust stuff out there, so let me just put links to some
103 // of the most interesting places here:
104 // 
105 // * [The Rust Book](https://doc.rust-lang.org/stable/book/)
106 // * [Rust by Example](http://rustbyexample.com/)
107 // * The [Rust Subreddit](https://www.reddit.com/r/rust/)
108 // * For the IRC channel and other forums, see the "Community" section of the [Rust Documentation index](http://doc.rust-lang.org/index.html)