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