|
3 | 3 |
|
4 | 4 | Small exercises to get you used to reading and writing [Rust](https://www.rust-lang.org) code - _Recommended in parallel to reading [the official Rust book](https://doc.rust-lang.org/book) 📚️_ |
5 | 5 |
|
6 | | -<!-- toc --> |
| 6 | +<script src="https://asciinema.org/a/719805.js" id="asciicast-719805" async="true"></script> |
7 | 7 |
|
8 | | -## Getting Started |
9 | | - |
10 | | -### Installing Rust |
11 | | - |
12 | | -Before installing Rustlings, you need to have the **latest version of Rust** installed. |
13 | | -Visit [www.rust-lang.org/tools/install](https://www.rust-lang.org/tools/install) for further instructions on installing Rust. |
14 | | -This will also install _Cargo_, Rust's package/project manager. |
15 | | - |
16 | | -> 🐧 If you are on Linux, make sure you have installed `gcc` (for a linker). |
17 | | -> |
18 | | -> Deb: `sudo apt install gcc` |
19 | | -> |
20 | | -> Dnf: `sudo dnf install gcc` |
21 | | -
|
22 | | -> 🍎 If you are on MacOS, make sure you have installed Xcode and its developer tools by running `xcode-select --install`. |
23 | | -
|
24 | | -### Installing Rustlings |
25 | | - |
26 | | -The following command will download and compile Rustlings: |
| 8 | +## Quick start |
27 | 9 |
|
28 | 10 | ```bash |
| 11 | +# Installation |
29 | 12 | cargo install rustlings |
30 | | -``` |
31 | | - |
32 | | -<details> |
33 | | -<summary><strong>If the installation fails…</strong> (<em>click to expand</em>)</summary> |
34 | | - |
35 | | -- Make sure you have the latest Rust version by running `rustup update` |
36 | | -- Try adding the `--locked` flag: `cargo install rustlings --locked` |
37 | | -- Otherwise, please [report the issue](https://github.com/rust-lang/rustlings/issues/new) |
38 | | - |
39 | | -</details> |
40 | | - |
41 | | -### Initialization |
42 | | - |
43 | | -After installing Rustlings, run the following command to initialize the `rustlings/` directory: |
44 | | - |
45 | | -```bash |
| 13 | +# Initialization |
46 | 14 | rustlings init |
47 | | -``` |
48 | | - |
49 | | -<details> |
50 | | -<summary><strong>If the command <code>rustlings</code> can't be found…</strong> (<em>click to expand</em>)</summary> |
51 | | - |
52 | | -You are probably using Linux and installed Rust using your package manager. |
53 | | - |
54 | | -Cargo installs binaries to the directory `~/.cargo/bin`. |
55 | | -Sadly, package managers often don't add `~/.cargo/bin` to your `PATH` environment variable. |
56 | | - |
57 | | -The solution is to … |
58 | | - |
59 | | -- either add `~/.cargo/bin` manually to `PATH` |
60 | | -- or to uninstall Rust from the package manager and install it using the official way with `rustup`: https://www.rust-lang.org/tools/install |
61 | | - |
62 | | -</details> |
63 | | - |
64 | | -Now, go into the newly initialized directory and launch Rustlings for further instructions on getting started with the exercises: |
65 | | - |
66 | | -```bash |
67 | | -cd rustlings/ |
| 15 | +# Moving into new directory |
| 16 | +cd rustlings |
| 17 | +# Starting Rustlings |
68 | 18 | rustlings |
69 | 19 | ``` |
70 | 20 |
|
71 | | -## Working environment |
72 | | - |
73 | | -### Editor |
74 | | - |
75 | | -Our general recommendation is [VS Code](https://code.visualstudio.com/) with the [rust-analyzer plugin](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer). |
76 | | -But any editor that supports [rust-analyzer](https://rust-analyzer.github.io/) should be enough for working on the exercises. |
77 | | - |
78 | | -### Terminal |
79 | | - |
80 | | -While working with Rustlings, please use a modern terminal for the best user experience. |
81 | | -The default terminal on Linux and Mac should be sufficient. |
82 | | -On Windows, we recommend the [Windows Terminal](https://aka.ms/terminal). |
83 | | - |
84 | | -## Doing exercises |
85 | | - |
86 | | -The exercises are sorted by topic and can be found in the subdirectory `exercises/<topic>`. |
87 | | -For every topic, there is an additional `README.md` file with some resources to get you started on the topic. |
88 | | -We highly recommend that you have a look at them before you start 📚️ |
89 | | - |
90 | | -Most exercises contain an error that keeps them from compiling, and it's up to you to fix it! |
91 | | -Some exercises contain tests that need to pass for the exercise to be done ✅ |
92 | | - |
93 | | -Search for `TODO` and `todo!()` to find out what you need to change. |
94 | | -Ask for hints by entering `h` in the _watch mode_ 💡 |
95 | | - |
96 | | -### Watch Mode |
97 | | - |
98 | | -After the [initialization](#initialization), Rustlings can be launched by simply running the command `rustlings`. |
99 | | - |
100 | | -This will start the _watch mode_ which walks you through the exercises in a predefined order (what we think is best for newcomers). |
101 | | -It will rerun the current exercise automatically every time you change the exercise's file in the `exercises/` directory. |
102 | | - |
103 | | -<details> |
104 | | -<summary><strong>If detecting file changes in the <code>exercises/</code> directory fails…</strong> (<em>click to expand</em>)</summary> |
105 | | - |
106 | | -> You can add the **`--manual-run`** flag (`rustlings --manual-run`) to manually rerun the current exercise by entering `r` in the watch mode. |
107 | | -> |
108 | | -> Please [report the issue](https://github.com/rust-lang/rustlings/issues/new) with some information about your operating system and whether you run Rustlings in a container or virtual machine (e.g. WSL). |
109 | | -
|
110 | | -</details> |
111 | | - |
112 | | -### Exercise List |
113 | | - |
114 | | -In the [watch mode](#watch-mode) (after launching `rustlings`), you can enter `l` to open the interactive exercise list. |
115 | | - |
116 | | -The list allows you to… |
117 | | - |
118 | | -- See the status of all exercises (done or pending) |
119 | | -- `c`: Continue at another exercise (temporarily skip some exercises or go back to a previous one) |
120 | | -- `r`: Reset status and file of the selected exercise (you need to _reload/reopen_ its file in your editor afterwards) |
121 | | - |
122 | | -See the footer of the list for all possible keys. |
123 | | - |
124 | | -## Questions? |
125 | | - |
126 | | -If you need any help while doing the exercises and the builtin-hints aren't helpful, feel free to ask in the [_Q&A_ category of the discussions](https://github.com/rust-lang/rustlings/discussions/categories/q-a?discussions_q=) if your question wasn't asked yet 💡 |
127 | | - |
128 | | -## Continuing On |
129 | | - |
130 | | -Once you've completed Rustlings, put your new knowledge to good use! |
131 | | -Continue practicing your Rust skills by building your own projects, contributing to Rustlings, or finding other open-source projects to contribute to. |
132 | | - |
133 | | -## Uninstalling Rustlings |
134 | | - |
135 | | -If you want to remove Rustlings from your system, run the following command: |
136 | | - |
137 | | -```bash |
138 | | -cargo uninstall rustlings |
139 | | -``` |
| 21 | +Visit the [**setup**](@/setup/index.md) page for more details 🧰 |
0 commit comments