rustlings/README-template.hbs

185 lines
6.5 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/stable/book/first-edition/variable-bindings.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/stable/book/first-edition/functions.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/stable/book/first-edition/primitive-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 Syntax and Semantics section of the book to cover tests-- many of the
following exercises will ask you to make tests pass!
[Testing chapter from the Effective Rust section of the
book](https://doc.rust-lang.org/stable/book/first-edition/testing.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/stable/book/first-edition/if.html)
{{ playground_link "if/if1.rs" }}
### Strings
[Relevant chapter in The Rust Programming
Language](https://doc.rust-lang.org/stable/book/first-edition/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/stable/book/first-edition/ownership.html)
- [References and
borrowing](https://doc.rust-lang.org/stable/book/first-edition/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/stable/book/first-edition/crates-and-modules.html)
{{ playground_link "modules/modules1.rs" }}
{{ playground_link "modules/modules2.rs" }}
### Macros
[Check out the Macros section of the
book](https://doc.rust-lang.org/book/first-edition/macros.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/stable/book/first-edition/error-handling.html) and
[Generics](https://doc.rust-lang.org/stable/book/first-edition/generics.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/stable/book/first-edition/concurrency.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/stable/book/first-edition/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/first-edition/dining-philosophers.html) and the
[Concurrency Chapter](https://doc.rust-lang.org/stable/book/first-edition/concurrency.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??