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.
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 ;-)
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.
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.
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 Book](https://doc.rust-lang.org/stable/book/).
43 // This will also install `cargo`, the tool responsible for building rust projects (or *crates*).
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
47 // [download the workspace](https://www.ralfj.de/projects/rust-101/workspace.zip)
48 // matching the online tutorial. Try `cargo build` in that new folder to check that compiling your
49 // workspace succeeds.
50 // (You can also execute it with `cargo run`, but you'll need to do some work before this does
53 // Alternatively, you can build the workspace from source by fetching the
54 // [git repository](https://www.ralfj.de/git/rust-101.git) and running `make workspace`.
59 // Open `your-workspace/src/part00.rs` in your favorite editor, and follow the link below for
60 // the explanations and exercises. You are ready to start. Have fun!
64 // * [Part 00: Algebraic datatypes](part00.html)
65 // * [Part 01: Expressions, Inherent methods](part01.html)
66 // * [Part 02: Generic types, Traits](part02.html)
67 // * [Part 03: Input](part03.html)
71 // * [Part 04: Ownership, Borrowing, References](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 // * [Part 08: Associated Types, Modules](part08.html)
76 // * [Part 09: Iterators](part09.html)
77 // * [Part 10: Closures](part10.html)
81 // * [Part 11: Trait Objects, Box, Lifetime bounds](part11.html)
82 // * [Part 12: Rc, Interior Mutability, Cell, RefCell](part12.html)
83 // * [Part 13: Concurrency, Arc, Send](part13.html)
84 // * [Part 14: Slices, Arrays, External Dependencies](part14.html)
85 // * [Part 15: Mutex, Interior Mutability (cont.), RwLock, Sync](part15.html)
86 // * [Part 16: Unsafe Rust, Drop](part16.html)
88 #![allow(dead_code, unused_imports, unused_variables, unused_mut, unreachable_code)]
107 // To actually run the code of some part (after filling in the blanks, if necessary), simply edit
108 // the `main` function.
114 // Additional material
115 // -------------------
117 // There's tons of useful Rust stuff out there, so let me just put links to some
118 // of the most interesting places here:
120 // * [The Rust Book](https://doc.rust-lang.org/stable/book/)
121 // * [The Rustonomicon](https://doc.rust-lang.org/nightly/nomicon/)
122 // * [Rust by Example](https://doc.rust-lang.org/rust-by-example/)
123 // * The [Rust Subreddit](https://www.reddit.com/r/rust/)
124 // * A [collection of links](https://github.com/ctjhoa/rust-learning) to blog posts, articles,
125 // videos, etc. for learning Rust.
126 // * For the IRC channel and other forums, see the "Community" section of the
127 // [Rust Documentation index](https://doc.rust-lang.org/index.html)