This repository has been archived on 2023-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
rustlings-exercises-completed/README-template.hbs
2018-10-09 20:28:54 +02:00

191 lines
6.8 KiB
Handlebars

<!--
{{ autogenerated_notice }}
-->
# rustlings
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 :)
## To do these exercises
Thanks to [btbytes'](https://twitter.com/btbytes) [prlinks](https://github.com/btbytes/prlink), 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.
If you need more help or would like to compare solutions, you can ask in [#rust-beginners on
irc.mozilla.org](https://chat.mibbit.com/?server=irc.mozilla.org&channel=%23rust-beginners ), the
[user forum](https://users.rust-lang.org/), or [the subreddit](https://reddit.com/r/rust). If an
exercise could be improved in any way, please [create an
issue](https://github.com/carols10cents/rustlings/issues/new) or submit a pull request!
### Variable bindings
[Relevant chapter in The Rust Programming
Language](https://doc.rust-lang.org/book/second-edition/ch03-01-variables-and-mutability.html)
{{ playground_link "variables/variables1.rs" }}
{{ playground_link "variables/variables2.rs" }}
{{ playground_link "variables/variables3.rs" }}
{{ playground_link "variables/variables4.rs" }}
### Functions
[Relevant chapter in The Rust Programming
Language](https://doc.rust-lang.org/book/second-edition/ch03-03-how-functions-work.html)
{{ playground_link "functions/functions1.rs" }}
{{ playground_link "functions/functions2.rs" }}
{{ playground_link "functions/functions3.rs" }}
{{ playground_link "functions/functions4.rs" }}
{{ playground_link "functions/functions5.rs" }}
### Primitive types
[Relevant chapter in The Rust Programming
Language](https://doc.rust-lang.org/book/second-edition/ch03-02-data-types.html)
{{ playground_link "primitive_types/primitive_types1.rs" }}
{{ playground_link "primitive_types/primitive_types2.rs" }}
{{ playground_link "primitive_types/primitive_types3.rs" }}
{{ playground_link "primitive_types/primitive_types4.rs" }}
{{ playground_link "primitive_types/primitive_types5.rs" }}
{{ playground_link "primitive_types/primitive_types6.rs" }}
### Tests
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](https://doc.rust-lang.org/book/second-edition/ch11-01-writing-tests.html)
{{ playground_link "tests/tests1.rs" }}
{{ playground_link "tests/tests2.rs" }}
{{ playground_link "tests/tests3.rs" }}
{{ playground_link "tests/tests4.rs" }}
### If
[Relevant chapter in The Rust Programming
Language](https://doc.rust-lang.org/book/second-edition/ch03-05-control-flow.html)
{{ playground_link "if/if1.rs" }}
### Strings
[Relevant chapter in The Rust Programming
Language](https://doc.rust-lang.org/book/second-edition/ch08-02-strings.html)
{{ playground_link "strings/strings1.rs" }}
{{ playground_link "strings/strings2.rs" }}
{{ playground_link "strings/strings3.rs" }}
### Move semantics
These exercises are adapted from [pnkfelix]()'s [Rust
Tutorial](https://pnkfelix.github.io/rust-examples-icfp2014/) -- thank you Felix!!!
Relevant chapters in the book:
- [Ownership](https://doc.rust-lang.org/book/second-edition/ch04-01-what-is-ownership.html)
- [References and borrowing](https://doc.rust-lang.org/book/second-edition/ch04-02-references-and-borrowing.html)
Note that the exercises in this section may look similar to each other but they are subtly
different :)
{{ playground_link "move_semantics/move_semantics1.rs" }}
{{ playground_link "move_semantics/move_semantics2.rs" }}
{{ playground_link "move_semantics/move_semantics3.rs" }}
{{ playground_link "move_semantics/move_semantics4.rs" }}
### Modules
[Relevant chapter in The Rust Programming
Language](https://doc.rust-lang.org/book/second-edition/ch07-01-mod-and-the-filesystem.html)
{{ playground_link "modules/modules1.rs" }}
{{ playground_link "modules/modules2.rs" }}
### Macros
Check out:
- [The Macros section of the first edition of the book
book](https://doc.rust-lang.org/book/first-edition/macros.html)
- [The Macros appendix of the second edition of the
book](https://doc.rust-lang.org/book/second-edition/appendix-04-macros.html)
- [The Little Book of Rust Macros](https://danielkeep.github.io/tlborm/book/index.html)
{{ playground_link "macros/macros1.rs" }}
{{ playground_link "macros/macros2.rs" }}
{{ playground_link "macros/macros3.rs" }}
{{ playground_link "macros/macros4.rs" }}
### Error Handling
The [Error
Handling](https://doc.rust-lang.org/book/second-edition/ch09-02-recoverable-errors-with-result.html)
and [Generics](https://doc.rust-lang.org/book/second-edition/ch10-01-syntax.html) sections are
relevant.
{{ playground_link "error_handling/option1.rs" }}
{{ playground_link "error_handling/result1.rs" }}
{{ playground_link "error_handling/errors1.rs" }}
{{ playground_link "error_handling/errors2.rs" }}
{{ playground_link "error_handling/errors3.rs" }}
{{ playground_link "error_handling/errorsn.rs" }}
### Standard library types
#### `Arc`
The [Concurrency](https://doc.rust-lang.org/book/second-edition/ch16-03-shared-state.html) section
is relevant.
{{ playground_link "standard_library_types/arc1.rs" }}
#### Iterators
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](https://doc.rust-lang.org/book/second-edition/ch13-02-iterators.html) and the [Iterator
docs](https://doc.rust-lang.org/stable/std/iter/trait.Iterator.html).
{{ playground_link "standard_library_types/iterator3.rs" }}
{{ playground_link "standard_library_types/iterators4.rs" }}
### Threads
See [the Dining Philosophers
example](https://doc.rust-lang.org/1.4.0/book/dining-philosophers.html) and the
[Concurrency Chapter](https://doc.rust-lang.org/book/second-edition/ch16-01-threads.html) from the
book.
{{ playground_link "threads/threads1.rs" }}
### Uncategorized
A few exercises based on things I've encountered or had trouble with getting used to.
{{ playground_link "ex1.rs" }}
{{ playground_link "ex2.rs" }}
{{ playground_link "ex3.rs" }}
{{ playground_link "ex4.rs" }}
{{ playground_link "ex5.rs" }}
## To help with this repo/TODO list
* 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??