Small exercises to get you used to reading and writing Rust code. Includes practice reading and responding to compiler messages!
This repo is very much the smallest thing that could possibly work :)
Thanks to btbytes' prlinks, you can now click on the links below to load the exercises in the rust playground!
There are infinite correct answers-- the exercises are sometimes left very open-ended. Scroll down in the playground to find comments that have hints.
- clone the repo to your local environment:
git clone https://github.com/rustlings/rustlings.git
- edit the rustling that you want, per example
variables/variables1.rs
- run
cargo run
in the project folder - you will notice that your README file was modified and now it has the new content of the file that you edited
- click in the new URL in the README and you will redirect to the rust playground and the whole file content it will be loaded
- to execute in the rust playground, just click on
run
If you need more help or would like to compare solutions, you can ask in #rust-beginners on irc.mozilla.org, the user forum, or the subreddit. If an exercise could be improved in any way, please create an issue or submit a pull request!
Relevant chapter in The Rust Programming Language
Relevant chapter in The Rust Programming Language
Relevant chapter in The Rust Programming Language
- "primitive_types1.rs"
- "primitive_types2.rs"
- "primitive_types3.rs"
- "primitive_types4.rs"
- "primitive_types5.rs"
- "primitive_types6.rs"
Going out of order from the book to cover tests-- many of the following exercises will ask you to make tests pass!
Relevant chapter in The Rust Programming Language
Relevant chapter in The Rust Programming Language
Relevant chapter in The Rust Programming Language
These exercises are adapted from pnkfelix's Rust Tutorial -- thank you Felix!!!
Relevant chapters in the book:
Note that the exercises in this section may look similar to each other but they are subtly different :)
Relevant chapter in The Rust Programming Language
Check out:
The Error Handling and Generics sections are relevant.
The Concurrency section is relevant.
Do not adjust your monitors-- iterators 1 and 2 are indeed missing. Iterator 3 is a bit challenging so we're leaving space for some exercises to lead up to it!
Check out the Iterators chapter of the book and the Iterator docs.
See the Dining Philosophers example and the Concurrency Chapter from the book.
A few exercises based on things I've encountered or had trouble with getting used to.
- File issues for problems or suggestions!
- Contribute more exercises! Anything that took you time to get used to, or that you had trouble with, or that deserves practice would be a good exercise!
- How could the process of doing these exercises work better? This is an open-ended question :) Are the playground links good enough? Are there ways that we could make going to the next exercise easier without forking the playground??