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.2.
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*).
45 // Next, fetch the Rust-101 source code from the [git repository](https://www.ralfj.de/git/rust-101.git)
46 // (also available [on GitHub](https://github.com/RalfJung/rust-101), and as a
47 // [zip archive](https://github.com/RalfJung/rust-101/archive/master.zip) in case you don't have git installed).
49 // There is a workspace prepared for you in the `workspace` folder. I suggest you copy this
50 // folder somewhere else. 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.)
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!
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)
68 // * [Part 04: Ownership, Borrowing](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)
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)
85 #![allow(dead_code, unused_imports, unused_variables, unused_mut, unreachable_code)]
104 // To actually run the code of some part (after filling in the blanks, if necessary), simply edit the `main`
111 // Additional material
112 // -------------------
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:
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)