rustlings/README-template.hbs

191 lines
6.8 KiB
Handlebars
Raw Normal View History

<!--
{{ autogenerated_notice }}
-->
# rustlings
2018-03-04 21:42:44 +03:00
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
2018-03-04 21:42:44 +03:00
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!
2018-03-04 21:42:44 +03:00
There are infinite correct answers-- the exercises are sometimes left very open-ended. Scroll down
in the playground to find comments that have hints.
2018-03-04 21:42:44 +03:00
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
2018-03-04 21:42:44 +03:00
[Relevant chapter in The Rust Programming
2018-03-05 00:31:07 +03:00
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
2018-03-04 21:42:44 +03:00
[Relevant chapter in The Rust Programming
2018-03-05 00:31:07 +03:00
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
2018-03-04 21:42:44 +03:00
[Relevant chapter in The Rust Programming
2018-03-05 00:31:07 +03:00
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
2018-03-05 00:31:07 +03:00
Going out of order from the book to cover tests-- many of the following exercises will ask you to
make tests pass!
2018-03-05 00:31:07 +03:00
[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
2018-03-04 21:42:44 +03:00
[Relevant chapter in The Rust Programming
2018-03-05 00:31:07 +03:00
Language](https://doc.rust-lang.org/book/second-edition/ch03-05-control-flow.html)
{{ playground_link "if/if1.rs" }}
### Strings
2018-03-04 21:42:44 +03:00
[Relevant chapter in The Rust Programming
2018-03-05 00:31:07 +03:00
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
2018-03-04 21:42:44 +03:00
These exercises are adapted from [pnkfelix]()'s [Rust
Tutorial](https://pnkfelix.github.io/rust-examples-icfp2014/) -- thank you Felix!!!
Relevant chapters in the book:
2018-03-04 21:42:44 +03:00
2018-03-05 00:31:07 +03:00
- [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)
2018-03-04 21:42:44 +03:00
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
2018-03-04 21:42:44 +03:00
[Relevant chapter in The Rust Programming
2018-03-05 00:31:07 +03:00
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
2018-03-05 00:31:07 +03:00
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
2018-03-05 00:31:07 +03:00
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`
2018-03-05 00:31:07 +03:00
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
2018-03-04 21:42:44 +03:00
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!
2018-03-04 21:42:44 +03:00
Check out the [Iterators chapter of the
2018-03-05 00:31:07 +03:00
book](https://doc.rust-lang.org/book/second-edition/ch13-02-iterators.html) and the [Iterator
2018-03-04 21:42:44 +03:00
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
2018-03-04 21:42:44 +03:00
See [the Dining Philosophers
2018-10-09 21:28:54 +03:00
example](https://doc.rust-lang.org/1.4.0/book/dining-philosophers.html) and the
2018-03-05 00:31:07 +03:00
[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!
2018-03-04 21:42:44 +03:00
* 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??