some things are no longer WIP
[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. I am writing this with a tutorial situation in mind, i.e.,
9 // with a teacher being around to guide students through the course and answer
10 // questions as they come up. However, I think they may also be useful if you
11 // work through them on your own, you will just have to show more initiative yourself:
12 // Make sure you actually type some code. It may sound stupid to manually copy code
13 // that you could duplicate through the clipboard, but it's actually helpful.
14 // If you have questions, check out the "Additional Resources" below. In particular,
15 // the IRC channel is filled with awesome people willing to help you! I spent
16 // lots of time there ;-)
17 // 
18 // I will assume some familiarity with programming, and hence not explain the basic
19 // concepts common to most languages. Instead, I will focus on what makes Rust special.
20 //
21 // Why Rust?
22 // ---------
23 // 
24 // When you got here, I am kind of assuming that you already decided to give Rust at
25 // least a look, so that I don't have to do much convincing here ;-) . But just in
26 // case, here's why I think Rust is worth learning:<br/>
27 // At this time, Rust is a language with a pretty unique set of goals. Rust aims to
28 // achieve C++-style control over memory and execution behavior (like, static vs. dynamic
29 // dispatch), which makes it possible to construct abstractions that carry no run-time
30 // cost. This is combined this with providing the comfort of high-level functional languages
31 // and guaranteeing safety (as in, the program will not crash). The vast majority of existing
32 // languages sacrificies one of these goals for the other. In particular, the
33 // first requirement rules out a garbage collector: Rust can run "mare metal".
34 // In fact, Rust rules out more classes of bugs than languages that achieve safety
35 // with a GC: Besides dangling pointers and double-free, Rust also prevents issues
36 // such as iterator invalidation and race conditions.
37 // 
38 // 
39 // Getting started
40 // ---------------
41 // 
42 // You will need to have Rust installed, of course. It is available for download on
43 // [the Rust website](http://www.rust-lang.org/). At this point, I plan to restrict
44 // myself to stable Rust, so "Recommended" version is just right.
45 // You can find some more installation instructions in
46 // [the second chapter of The Book](https://doc.rust-lang.org/stable/book/installing-rust.html).
47
48 // Next, fetch the Rust-101 source code from the [git repository](http://www.ralfj.de/git/rust-101.git)
49 // (also available [on GitHub](https://github.com/RalfJung/rust-101)). Running `cargo build`
50 // in the root of the repository should now succeed.
51 // 
52 // I suggest you copy the folder `workspace` somewhere you like, so that you can still easily
53 // `git pull` updates in the main repository. After copying, try `cargo build` in the
54 // new location. It should complain about `part00::main()` not being found. Now you can start
55 // by following [Part 00](part00.html), typing in `part00.rs`. If you need to add a new file, remember to also
56 // add it to `main.rs` so that Rust finds it.
57 // 
58 // If you do not want to copy all the code yourself, and wish to start with my code and just edit
59 // it, you can copy the files from `src` in this repository, to `src` in your workspace copy.
60
61 // Course Content
62 // --------------
63 // 
64 // The actual course is in the partXX.rs files. The part 00-03 cover some basic of the language,
65 // to give you a feeling for Rust's syntax and pervasive mechanisms like pattern matching and traits.
66 // Parts 04-06 introduce the heart of the language, the mechanism making it different from anything
67 // else out there: Ownership, borrowing, lifetimes. In part 07-??, we continue our tour through
68 // Rust. Finally, in parts ??-??, we implement our own version of `grep`, exhibiting useful Rust
69 // features as we go.
70 // 
71 // You should start with [the first part](part00.html), or jump directly to where you left off:
72 // 
73 // * [Part 00: Algebraic datatypes](part00.html)
74 // * [Part 01: Expressions, Inherent methods](part01.html)
75 // * [Part 02: Generic types, Traits](part02.html)
76 // * [Part 03: Input](part03.html)
77 // * [Part 04: Ownership, Borrowing](part04.html)
78 // * [Part 05: Clone](part05.html)
79 // * [Part 06: Copy, Lifetimes](part06.html)
80 // * [Part 07: Operator Overloading, Tests, Formating](part07.html)
81 // * (to be continued)
82 #![allow(dead_code, unused_imports, unused_variables, unused_mut)]
83 mod part00;
84 mod part01;
85 mod part02;
86 mod part03;
87 mod part04;
88 mod part05;
89 mod part06;
90 mod part07;
91 mod part08;
92 mod part09;
93
94 // To actually run the code of some part (after filling in the blanks, if necessary), simply edit the `main`
95 // function.
96
97 fn main() {
98     part03::main();
99 }
100
101 // Additional material
102 // -------------------
103 // 
104 // There's tons of useful Rust stuff out there, so let me just put links to some
105 // of the most interesting places here:
106 // 
107 // * [The Rust Book](https://doc.rust-lang.org/stable/book/)
108 // * [Rust by Example](http://rustbyexample.com/)
109 // * The [Rust Subreddit](https://www.reddit.com/r/rust/)
110 // * For the IRC channel and other forums, see the "Community" section of the [Rust Documentation index](http://doc.rust-lang.org/index.html)