Compare commits

...

721 commits
1.0.0 ... main

Author SHA1 Message Date
red 84bb490545 PARTIALLY SOLVED 2021-07-07 21:03:42 +01:00
red aa2ce0ee19 SOLVED 2021-07-07 21:02:31 +01:00
red f1bf7b5735 UNSOLVED 2021-07-07 20:58:36 +01:00
red f81fe2b60c Delete excercies 2021-07-07 20:57:20 +01:00
red 5b989095cd Update 'README.md' 2021-07-07 19:49:15 +00:00
marisa cdd8e19716
Merge pull request from rust-lang/all-contributors/add-cseltol
docs: add cseltol as a contributor for doc
2021-07-05 18:57:05 +02:00
allcontributors[bot] 91d86a1de9
docs: update .all-contributorsrc [skip ci] 2021-07-05 16:56:57 +00:00
allcontributors[bot] 6a10f900b4
docs: update README.md [skip ci] 2021-07-05 16:56:56 +00:00
marisa 9b9a89c79a
Merge pull request from cseltol/main
fix(installation): first PowerShell command
2021-07-05 18:56:34 +02:00
marisa 123e6426d1
Merge pull request from kolbma/exercise-clippy1-hint-390
chore: clippy1 hint enhancement
2021-06-30 12:10:02 +02:00
marisa 427ec6b2e4
Merge pull request from rust-lang/all-contributors/add-jazzplato
docs: add jazzplato as a contributor for code
2021-06-30 12:06:16 +02:00
allcontributors[bot] 03dcb582e6
docs: update .all-contributorsrc [skip ci] 2021-06-30 10:06:07 +00:00
allcontributors[bot] 1043a06124
docs: update README.md [skip ci] 2021-06-30 10:06:06 +00:00
Richthofen d20e413a68
feat(cli): Add "next" to run the next unsolved exercise. ()
* Add "run next" to run the next unsolved exercise.

* Fix a grammar error in the message.

* Update README.md with the suggested change

Co-authored-by: marisa <mokou@fastmail.com>

* Update the README.md for "rustlings hint next".

Co-authored-by: marisa <mokou@fastmail.com>
2021-06-30 12:05:49 +02:00
arlecchino 9bf4c5e8df
chore: clippy1 hint enhancement
Added some explanation and links about floating point representation and to use the clippy suggestion. (fixes )
2021-06-29 20:47:32 +02:00
marisa 633303d4b8
Merge pull request from kolbma/exercise-iterator3-hint
chore: Update hint of iterators3
2021-06-29 13:49:17 +02:00
arlecchino a4a1098766
Update info.toml
Co-authored-by: marisa <mokou@fastmail.com>
2021-06-29 13:41:16 +02:00
marisa 0bd459dcac
Merge pull request from rust-lang/all-contributors/add-kolbma
docs: add kolbma as a contributor for doc
2021-06-29 12:46:49 +02:00
allcontributors[bot] 3b4514b686
docs: update .all-contributorsrc [skip ci] 2021-06-29 10:46:41 +00:00
allcontributors[bot] 2e05606edc
docs: update README.md [skip ci] 2021-06-29 10:46:40 +00:00
marisa c8c1b87a01
Merge pull request from kolbma/git-clone-release-tag
docs: Faster git clone command
2021-06-29 12:46:28 +02:00
arlecchino 34ea029df8
chore: Update hint of iterators3
`collect()` needs some hint for standard_library_types/iterators3 exercise with doc link for understanding different return types via `FromIterator`.
2021-06-29 12:03:18 +02:00
arlecchino 3a4433d5a2
docs: Faster git clone command
Clone only release tag without history
2021-06-28 17:08:53 +02:00
marisa de6c45ad24
Merge pull request from rust-lang/all-contributors/add-hyperparabolic
docs: add hyperparabolic as a contributor for code
2021-06-24 14:18:02 +02:00
allcontributors[bot] fadade8592
docs: update .all-contributorsrc [skip ci] 2021-06-24 12:17:32 +00:00
allcontributors[bot] d91044f3a2
docs: update README.md [skip ci] 2021-06-24 12:17:31 +00:00
marisa a3ea37b76e
Merge pull request from tlyu/iterators5-trait-tweak
fix(iterators5): derive Clone, Copy
2021-06-24 14:17:05 +02:00
marisa ec63cadadb
Merge pull request from tlyu/errors-rework
feature: improve error_handling exercises
2021-06-24 14:12:34 +02:00
marisa 84d8305730
Merge pull request from rust-lang/all-contributors/add-kayuapi
docs: add kayuapi as a contributor for content
2021-06-24 14:10:33 +02:00
allcontributors[bot] 73777980f1
docs: update .all-contributorsrc [skip ci] 2021-06-24 12:10:24 +00:00
allcontributors[bot] 75788b1148
docs: update README.md [skip ci] 2021-06-24 12:10:23 +00:00
marisa dd9b2ddc89
Merge pull request from kayuapi/patch-1
fix(variables5): confine the answer further
2021-06-24 14:10:02 +02:00
Taylor Yu b7ddd09fab address review feedback
Adjust error text and naming to conform with best practices.
Use `map_err()` instead of `or()`. Wrap lower-level errors instead of
ignoring their details.

Also, don't "cheat" by bypassing the `new()` function in tests.

Fix a dangling reference in the try_from_into hints.
2021-06-09 23:27:53 -05:00
ZC 48ffcbd2c4
fix(variables5): confine the answer further
let mut number = 3; can lead to a correct answer, so the comment helps to direct the users to the intended answer.
2021-06-07 18:22:55 +08:00
Taylor Yu 68d3ac567c feature: improve error_handling exercises
Add new exercises errors5 and errors6, to introduce boxed errors and
custom error enums more gently. Delete errorsn, because it tried to do
too much too soon.
2021-06-06 23:08:57 -05:00
Taylor Yu 50ab289da6 fix: rename result1 to errors4
Also put it in the ERROR HANDLING section where it probably belongs.
2021-06-06 23:08:54 -05:00
Taylor Yu 4e079fdd08 chore(iterators5): conciseness hint 2021-06-06 17:45:35 -05:00
Taylor Yu 91fc9e3118 fix(iterators5): derive Clone, Copy
To allow more flexibility in solutions, derive `Clone` and `Copy`
for `Progress`.
2021-06-06 17:38:02 -05:00
marisa a2f0401c4c
Merge pull request from tlyu/move-semantics5-fixes
fix: move_semantics5 hints
2021-05-23 15:41:56 +02:00
Taylor Yu 1b85828548 fix: move_semantics5 hints
Improve the hints for move_semantics5, as well as the explanatory
comments in the code.

Previously, it was not clear what possible changes were allowed.
It seems that reordering the statements might be the intended solution.
The previous comment about not "adding newlines" doesn't make sense,
so treating it as "adding new lines" makes it more clear.
2021-05-22 22:09:58 -05:00
Taylor Yu 4c46e5e1a3 chore: minor typos in move_semantics5 hints 2021-05-22 21:56:14 -05:00
marisa 4da9e7ee29
Merge pull request from rust-lang/all-contributors/add-sateeshkumarb
docs: add sateeshkumarb as a contributor
2021-05-17 14:11:15 +02:00
allcontributors[bot] 72e615aa7a
docs: update .all-contributorsrc [skip ci] 2021-05-17 12:11:05 +00:00
allcontributors[bot] cd02abc481
docs: update README.md [skip ci] 2021-05-17 12:11:04 +00:00
Sateesh 399ab328d8
feat: Add move_semantics5 exercise. ()
* feat: Add move_semantics5 exercise.

* feat: Add option3 exercise

* Address review comments. Fix typos, sentence formatting.

* Remove unwanted newline.

* Address review comments: make comment inline, fix format in print.
2021-05-17 14:10:40 +02:00
marisa 809ec2ce01
Merge pull request from tlyu/dyn-error-hints
fix(try_from_into, from_str): hints for dyn Error
2021-05-17 14:09:44 +02:00
Taylor Yu 11d2cf0d60 fix(try_from_into, from_str): hints for dyn Error
Add hints about how to return the correct type for functions that
return `Result<_, Box<dyn Error>`. Some feedback from Discord suggests
that people run into trouble with that.
2021-05-15 14:01:17 -05:00
marisa dbb2624403
Merge pull request from juanprq/main
fix: remove trailing whitespace
2021-05-13 17:20:47 +02:00
Juan Pablo Ramirez 4d4fa77459 fix: remove trailing whitespaces from iterators1 2021-05-12 10:20:07 -05:00
Juan Pablo Ramirez 3145794084 fix: add hints to generics1 and generics2 exercises 2021-05-11 14:50:05 -05:00
Juan Pablo Ramirez d9b69bd1a0 fix: remove trailing whitespace 2021-05-09 17:58:54 -05:00
marisa 7cd635fa84
Merge pull request from rust-lang/all-contributors/add-PiDelport
docs: add PiDelport as a contributor
2021-05-01 12:12:51 +02:00
allcontributors[bot] ce40e201f0
docs: update .all-contributorsrc [skip ci] 2021-05-01 10:12:43 +00:00
allcontributors[bot] 404f3ef465
docs: update README.md [skip ci] 2021-05-01 10:12:42 +00:00
marisa e1be594fdd
Merge pull request from PiDelport/patch-1
style(standard_library_types): stray line break
2021-05-01 12:12:29 +02:00
Pi Delport 9569c9a9e7
style(standard_library_types): stray line break 2021-04-29 23:31:26 +02:00
marisa 91530f5716
Merge pull request from maartentibau/quiz1_add_explicit_test_40
chore: Update quiz1.rs add explicit test for 40
2021-04-27 10:20:50 +02:00
Maarten Tibau 650b1dee54
chore: Update quiz1.rs add explicit test for 40 2021-04-25 19:02:50 +02:00
marisa 6b6dc9dd48
Merge pull request from rust-lang/all-contributors/add-stoiandan
docs: add stoiandan as a contributor
2021-04-24 17:36:48 +02:00
allcontributors[bot] 3a9ec4192d
docs: update .all-contributorsrc [skip ci] 2021-04-24 15:36:39 +00:00
allcontributors[bot] 4f7dbbd2c3
docs: update README.md [skip ci] 2021-04-24 15:36:38 +00:00
marisa 8c37db1a23
Merge pull request from stoiandan/main
updated README.md; specify need for admin rights
2021-04-24 17:36:19 +02:00
Dan Stoian c6b7ad8878 updated README.md; specify need for admin rights 2021-04-24 18:32:13 +03:00
mokou 84461c20cb release: 4.4.0 2021-04-24 11:57:00 +02:00
marisa 3cddda56fc
Merge pull request from Zerotask/add-hint-corresponding-readme
chore(watch): add hint for the exercises README.md
2021-04-24 11:46:25 +02:00
marisa 37f3069a67
Merge pull request from Zerotask/update-dependencies
chore(deps): update cargo dependencies
2021-04-24 11:45:56 +02:00
marisa 2b2fbe918e
Merge pull request from Zerotask/update-exercises-readme
docs(exercises): consistent excersises README.md files
2021-04-24 11:45:37 +02:00
Zerotask cf42ddc449
chore(watch): add hint for the exercises README.md
rustlings watch will now show an additional hint for the corresponding README.me
2021-04-23 20:28:55 +02:00
Zerotask eefa656232
chore(deps): update cargo dependencies 2021-04-23 20:07:32 +02:00
Zerotask 249ad44cc0
docs(exercises): updated all exercises readme files
all exercises readme files now have a unified structure and a description
2021-04-23 19:54:31 +02:00
marisa 54804e344d
Merge pull request from Zerotask/add-further-help-for-generics3
docs(generics): add bounds help
2021-04-23 15:05:00 +02:00
marisa 1c334de6fd
Merge pull request from Zerotask/add-further-help-to-error-excersis
docs(errors): add additional help for Result/Boxing
2021-04-23 15:04:47 +02:00
Zerotask f253103a31
docs(generics): add bounds help
add help for bounds provided by the rust by example book
2021-04-22 22:11:04 +02:00
Zerotask 1120db57a6
docs(errors): add additional help for Result/Boxing
add additional help information provided by the rust by example book
2021-04-22 21:32:29 +02:00
marisa afa661cff4
Merge pull request from rust-lang/feat/declap
feat: Replace clap with argh
2021-04-21 16:33:07 +02:00
mokou 347f30bd86 fix(main): Let find_exercise work with borrows 2021-04-21 16:21:56 +02:00
marisa 127773f3f5
Merge pull request from rust-lang/all-contributors/add-bmacer
docs: add bmacer as a contributor
2021-04-21 14:50:37 +02:00
allcontributors[bot] 8d0490bd70
docs: update .all-contributorsrc [skip ci] 2021-04-21 12:50:27 +00:00
allcontributors[bot] 293dfb35d5
docs: update README.md [skip ci] 2021-04-21 12:50:26 +00:00
Brandon Macer 81be404487
feat(arc1): Add more details to description and hint ()
Co-authored-by: bmacer <bmacer@cisco.com>
Co-authored-by: marisa <mokou@fastmail.com>
Co-authored-by: Roberto Vidal <vidal.roberto.j@gmail.com>
2021-04-21 14:50:03 +02:00
mokou 6177b6e126 chore: Fix integration tests 2021-04-21 14:47:53 +02:00
marisa 79cc657917
Merge pull request from apogeeoak/iterator
Added iterators5.rs exercise.
2021-04-21 10:10:50 +02:00
mokou 7928122fce feat: Replace clap with argh
I’ve been wanting to do this for a while, but always procrastinated on it. We’ve been using Clap since the 2.0 rewrite, but Clap is known to be a fairly heavy library. Since Rustlings is usually peoples’ first contact with a Rust compilation, I think it’s in our best interests that this complation is as fast as possible. In effect, replacing Clap with the smaller, structopt-style `argh` reduces the amount of crates needing to be compiled from 82 to 60.

I also think this makes the code way easier to read, we don’t need to use Clap’s methods anymore, but can switch over to using pure Rust methods, e.g., switches are booleans, options are Option<String>s or the like, and subcommands are just structs.
2021-04-21 10:08:26 +02:00
apogeeoak 9c88ea9126 Improved iterators5.rs explanation. 2021-04-20 18:55:04 -04:00
marisa 2b766ef9f9
Merge pull request from apogeeoak/iterator2
Moved iterators2.rs errors out of tests.
2021-04-20 11:24:10 +02:00
marisa bd3d9ac9d5
Merge pull request from apogeeoak/iterator3
Enabled iterators3.rs to run without commented out tests.
2021-04-20 11:22:39 +02:00
marisa aa0db8379c
Merge pull request from rust-lang/all-contributors/add-hongshaoyang
docs: add hongshaoyang as a contributor
2021-04-20 11:19:49 +02:00
allcontributors[bot] eadd41a9ec
docs: update .all-contributorsrc [skip ci] 2021-04-20 09:19:39 +00:00
allcontributors[bot] fab2eb9833
docs: update README.md [skip ci] 2021-04-20 09:19:38 +00:00
Shao Yang Hong 6bd791f2f4
fix(structs): Add 5.3 to structs/README ()
Co-authored-by: Shao Yang Hong <shaoyang.hong@ninjavan.co>
2021-04-20 11:19:24 +02:00
marisa ec5f80dce1
Merge pull request from rust-lang/all-contributors/add-k12ish
docs: add k12ish as a contributor
2021-04-20 11:18:32 +02:00
allcontributors[bot] 65cdc856ae
docs: update .all-contributorsrc [skip ci] 2021-04-20 09:18:23 +00:00
allcontributors[bot] 472f61485e
docs: update README.md [skip ci] 2021-04-20 09:18:22 +00:00
k12ish b4de659438
fix(option2): Rename uninformative variables ()
Renaming uninformative names like `optional_value`, `value`, `optional_values_vec` and `value` helps users distinguish between the two parts of the task.
2021-04-20 11:18:05 +02:00
marisa a37a8818c8
Merge pull request from rust-lang/all-contributors/add-arthas168
docs: add arthas168 as a contributor
2021-04-20 11:16:25 +02:00
allcontributors[bot] bdf01aa174
docs: update .all-contributorsrc [skip ci] 2021-04-20 09:16:16 +00:00
allcontributors[bot] a941c69f09
docs: update README.md [skip ci] 2021-04-20 09:16:15 +00:00
Pete Pavlovski 72aaa15e6a
fix(hashmap2): Update incorrect assertion ()
The test description says "at least five types of fruit", but the test itself is checking for exactly five types of fruit, which was a bit misleading for newcomers like me :) 

A simple change from "==" to ">=" should do the trick and successfully check for the "at least" condition.
2021-04-20 11:15:49 +02:00
marisa 3a06de71a8
Merge pull request from Zerotask/list-command-added-to-readme
docs: added hint for rustlings list command
2021-04-20 11:10:38 +02:00
marisa 5e2b39a5c1
Merge pull request from rust-lang/all-contributors/add-Zerotask
docs: add Zerotask as a contributor
2021-04-20 11:09:41 +02:00
allcontributors[bot] 63c942233e
docs: update .all-contributorsrc [skip ci] 2021-04-20 09:09:31 +00:00
allcontributors[bot] 2612edc133
docs: update README.md [skip ci] 2021-04-20 09:09:30 +00:00
marisa e2ce9f42b5
Merge pull request from Zerotask/list-command-progress-info
feat(list): added progress info
2021-04-20 11:09:14 +02:00
Patrick Hintermayer 1c6f7e4b7b
feat(list): updated progress percentage 2021-04-19 09:39:05 +02:00
Zerotask e2c41903ad
docs: added hint for rustlings list command
Added hint for `rustlings list` to the "Doing exercises" section.
2021-04-18 16:07:30 +02:00
Zerotask bd48544e25
style: formatted files with rustfmt 2021-04-18 15:40:47 +02:00
Zerotask c0e3daacaf
feat(list): added progress info
Added a progress info at the bottom of the list for command: rustlings list

closes 
2021-04-18 15:37:41 +02:00
Abdou Seck f2ad3a6a0b
Merge pull request from WowSuchRicky/main
Rename 'Lichi' to 'Lychee' in the fruit example
2021-04-13 10:40:07 -04:00
Abdou Seck caf921a01f
Merge pull request from Morsicus/fix/collections-exercises-naming
Update collections exercises naming
2021-04-13 10:39:18 -04:00
WowSuchRicky b790bafc02 Rename lichi to lychee in the fruit example 2021-04-09 14:08:02 -07:00
Abdou Seck ad3cd54cce
Merge pull request from rust-lang/all-contributors/add-tlyu
docs: add tlyu as a contributor
2021-04-05 07:27:42 -04:00
allcontributors[bot] 1a6a725f88
docs: update .all-contributorsrc [skip ci] 2021-04-05 11:27:17 +00:00
allcontributors[bot] 1ad20d94ff
docs: update README.md [skip ci] 2021-04-05 11:27:16 +00:00
Abdou Seck 995c6f0fb1
Merge pull request from tlyu/trait-obj-tryfrom
fix: use trait objects for try_from_into and from_str
2021-04-05 07:26:19 -04:00
Taylor Yu c3e7b83178 fix: use trait objects for from_str
Use `Box<dyn error::Error>` to allow solutions to use `?` to propagate 
errors.
2021-04-04 18:56:10 -05:00
Taylor Yu 2e93a588e0 fix: use trait objects for try_from_into
Use `Box<dyn error::Error>` to allow solutions to use `?` to propagate
errors.  In the tests, explicitly check `is_ok()` instead of trying to
force the error type to `String` (or other `PartialEq` type) using
`assert_eq!()`.
2021-04-04 12:41:32 -05:00
marisa 9aeca3f97e
Merge pull request from rust-lang/all-contributors/add-flakolefluk
docs: add flakolefluk as a contributor
2021-04-04 09:44:02 +02:00
allcontributors[bot] 2193fff4bb
docs: update .all-contributorsrc [skip ci] 2021-04-04 07:43:51 +00:00
allcontributors[bot] aec2c65c63
docs: update README.md [skip ci] 2021-04-04 07:43:50 +00:00
Ignacio Le Fluk a6509cc4d5
fix(functions3): improve function argument type () 2021-04-04 09:43:25 +02:00
marisa a02b279750
chore: Provide a working Windows installation link 2021-03-23 09:10:40 +01:00
marisa ece841f5ce
Merge pull request from rust-lang/all-contributors/add-blerchy
docs: add blerchy as a contributor
2021-03-22 13:37:10 +01:00
allcontributors[bot] 2a6e4dc8a6
docs: update .all-contributorsrc [skip ci] 2021-03-22 12:37:02 +00:00
allcontributors[bot] c163011cc0
docs: update README.md [skip ci] 2021-03-22 12:37:01 +00:00
marisa b350945a16
Merge pull request from blerchy/feat/no-emoji
Replace emojis when NO_EMOJI env variable present
2021-03-22 13:36:26 +01:00
marisa 1ef368a69d
Merge pull request from rust-lang/new-install-urls
chore: Update install URLs
2021-03-21 16:35:44 +01:00
marisa 8dc587b01a
chore: Update install URLs 2021-03-21 16:34:21 +01:00
allcontributors[bot] 550c4293ed
docs: add chapeupreto as a contributor ()
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2021-03-20 21:13:35 +01:00
Rod Elias 3df094713f
chore: capitalize c letter
By capitalizing the `c` letter it makes clear that we're talking about the C programming language.
2021-03-20 21:12:49 +01:00
Matt Lebl 01e7f27aa6 refactor: change from match to if for NO_EMOJI 2021-03-20 11:53:40 -07:00
Matt Lebl 8d62a99637 feat: Replace emojis when NO_EMOJI env variable present 2021-03-19 02:16:07 -07:00
Mickael Fortunato ab9995e76e doc: Update collections exercises instruction to match the standard naming 2021-03-18 19:11:15 +01:00
Mickael Fortunato bef39b1259 fix(collections): Naming exercises for vectors and hashmap 2021-03-18 19:11:04 +01:00
Pascal H 0d894e6ff7
fix(quiz3): Force an answer to Q2 ()
Add also an example of unimplemented!() macro.
2021-03-16 10:14:25 +01:00
allcontributors[bot] be9510539e
docs: add hpwxf as a contributor ()
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2021-03-15 09:14:41 +01:00
Pascal H 3bce2ef8d6
chore: clarify collections documentation
C++ `map` is more like BTreeMap.

`unordered_map` in C++(11) is the equivalent of `HashMap` in Rust.
(+ additional like for references).
2021-03-15 09:14:12 +01:00
Ivan Nerazumov aa9a943ddf
fix(installation): first PowerShell command
ExecutionPolicy to RemoteSigned command was fixed because the old command was getting denied access to change the Execution Policy property
2021-03-13 18:45:52 +07:00
Darius Wiles ebdb66c7bf
fix(structs2): correct grammar in hint () 2021-03-13 12:14:44 +01:00
Darius Wiles 9f3e8c2dde
fix(structs3): reword heading comment () 2021-03-13 12:14:02 +01:00
apogeeoak 96c56ab08a
chore: changed errors3 mode from test to compile 2021-03-12 20:04:29 +01:00
allcontributors[bot] 04dbf03ace
docs: add cadolphs as a contributor ()
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2021-03-12 18:37:58 +01:00
cadolphs 05a753fe63
fix: add check to prevent naive implementation of is_international
* fix(structs3): Add check to prevent naive implementation

* chore(structs3): Add a missed newline after the test I added
2021-03-12 18:36:35 +01:00
allcontributors[bot] 815edb7003
docs: add cjwyett as a contributor ()
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2021-03-12 15:39:40 +01:00
Cyrus Wyett 5157f56875
chore: fix typo
is however some --> are however some
2021-03-12 15:38:28 +01:00
allcontributors[bot] 3f5abca215
docs: add circumspect as a contributor
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2021-03-12 15:28:03 +01:00
circumspect 833df0b8b3
chore: fix typo
Co-authored-by: Chenkail <40770208+Chenkail@users.noreply.github.com>
2021-03-12 15:26:57 +01:00
marisa 6742860ea5
Merge pull request from rust-lang/all-contributors/add-Crell
docs: add Crell as a contributor
2021-02-25 11:21:11 +01:00
allcontributors[bot] 797e6d45c0
docs: update .all-contributorsrc [skip ci] 2021-02-25 10:20:54 +00:00
allcontributors[bot] 320de0d921
docs: update README.md [skip ci] 2021-02-25 10:20:53 +00:00
marisa 5eed505d74
Merge pull request from Crell/spelling-fix
fix: Spelling error
2021-02-25 11:20:39 +01:00
Larry Garfield 91ee27f22b
fix: Spelling error 2021-02-24 15:03:26 -06:00
Jirka Kremser 5f7c89f85d
fix(from_str): Correct typos
typos in the comments
2021-02-21 21:50:17 +01:00
apogeeoak c6712dfccd fix(iterators3): Enabled iterators3.rs to run without commented out tests. 2021-02-12 15:36:53 -05:00
apogeeoak baf4ba175b fix(iterators2): Moved errors out of tests.
Closes 
2021-02-11 21:24:32 -05:00
apogeeoak b29ea17ea9 feat: Added iterators5.rs exercise. 2021-02-10 18:03:29 -05:00
marisa ab57c26cf9
Merge pull request from apogeeoak/clippy
Updated source to follow clippy suggestions.
2021-02-10 10:37:13 +01:00
marisa 98e5e8835e
Merge pull request from rust-lang/all-contributors/add-apogeeoak
docs: add apogeeoak as a contributor
2021-02-10 10:36:57 +01:00
allcontributors[bot] f5158ece1a
docs: update .all-contributorsrc [skip ci] 2021-02-10 09:36:48 +00:00
allcontributors[bot] d65b4a9a93
docs: update README.md [skip ci] 2021-02-10 09:36:47 +00:00
marisa 8404947bc0
Merge pull request from apogeeoak/contributing
Fixed grammar in contributing.md.
2021-02-10 10:36:04 +01:00
apogeeoak 2e84f34cf3 chore: Updated source to follow clippy suggestions. 2021-02-09 18:21:18 -05:00
apogeeoak 726805f064 docs: Fixed grammar in contributing.md. 2021-02-09 17:43:53 -05:00
marisa b4a4138559
Merge pull request from rust-lang/all-contributors/add-tal-zvon
docs: add tal-zvon as a contributor
2021-02-07 12:22:49 +01:00
allcontributors[bot] f1d2b3a39a
docs: update .all-contributorsrc [skip ci] 2021-02-07 11:22:33 +00:00
allcontributors[bot] 1f9d006858
docs: update README.md [skip ci] 2021-02-07 11:22:32 +00:00
Tal cc266d7d80
fix(move_semantics4): Remove redundant "instead" () 2021-02-07 12:22:13 +01:00
marisa fff72afe2e
Merge pull request from rust-lang/all-contributors/add-jbaber
docs: add jbaber as a contributor
2021-01-30 17:12:39 +01:00
allcontributors[bot] c1abd13b5c
docs: update .all-contributorsrc [skip ci] 2021-01-30 16:12:28 +00:00
allcontributors[bot] 75802c14b2
docs: update README.md [skip ci] 2021-01-30 16:12:27 +00:00
John Baber-Lucero cddc1e86e7
fix(info): Fix typo ()
Co-authored-by: John Baber-Lucero <git@frundle.com>
2021-01-30 17:12:06 +01:00
fmoko 24ea42ce61
Merge pull request from rust-lang/all-contributors/add-jfchevrette
docs: add jfchevrette as a contributor
2021-01-22 13:11:43 +01:00
allcontributors[bot] 6102e612fa
docs: update .all-contributorsrc [skip ci] 2021-01-22 12:11:34 +00:00
allcontributors[bot] 52bde71166
docs: update README.md [skip ci] 2021-01-22 12:11:33 +00:00
Abdou Seck 15a79cfe9c
Merge pull request from jfchevrette/patch-1
Fix instructions(steps) for conversions/from_str exercice
2021-01-21 08:10:25 -05:00
Jean-Francois Chevrette 15e71535f3 fix(from_str): test for error instead of unwrap/should_panic 2021-01-21 07:55:22 -05:00
mokou 9f988bfe29 docs: Remove duplicate uninstallation section 2021-01-17 13:00:50 +01:00
fmoko e8d1baa4b5
Merge pull request from AbdouSeck/improve-list-command
feat(cli): Improve the list command with options, and then some
2021-01-17 12:37:58 +01:00
Abdou Seck 8bbe4ff138 feat(cli): Improve the list command with options, and then some
1.
`rustlings list` should now display more than just the exercise names.
Information such as file paths and exercises statuses should be displayed.
The `--paths` option limits the displayed fields to only the path names; while the `--names`
option limits the displayed fields to only exercise names.
You can also control which exercises are displayed, by using the `--filter` option, or
the `--solved` or `--unsolved` flags.

Some use cases:
- Fetching pending exercise files with the keyword "conversion" to pass to my editor:
```sh
vim $(rustlings list --filter "conversion" --paths --unsolved)
```

- Fetching exercise names with keyword "conversion" to pass to `rustlings run`:
```sh
for exercise in $(rustlings list --filter "conversion" --names)
do
    rustlings run ${exercise}
done
```

2.
This should also fix , and will likely fix , as well.
That bug mentioned in those issues has to do with the way the `watch` command handler fetches the pending exercises.
Going forward, the least recently updated exercises along with all the other exercises in a pending state are fetched.
2021-01-08 13:21:00 -05:00
Abdou Seck 0b9220c1fc Add looks_done method to Exercise to expose a resolution state 2021-01-08 13:21:00 -05:00
Abdou Seck 0d65753fdb
Merge pull request from lntuition/conversions_more_utc
feat(conversions): Add more unit tests to `from_str` and `from_into` exercises.
2021-01-08 13:18:24 -05:00
Sang-Heon Jeon 4f1374a6e7 feat(from_into) : add test for checking unnecessary trailing value 2021-01-09 00:08:38 +09:00
Sang-Heon Jeon 5a0521e92c feat(from_str) : add test for checking unnecessary trailing value 2021-01-09 00:07:13 +09:00
fmoko fea86c29d6
chore: Remove Readme GIF 2021-01-08 14:01:04 +01:00
fmoko 9c4614f7e6
Merge pull request from rust-lang/all-contributors/add-chrizel
docs: add chrizel as a contributor
2021-01-06 16:54:47 +01:00
allcontributors[bot] c24a78ae94
docs: update .all-contributorsrc [skip ci] 2021-01-06 15:54:34 +00:00
allcontributors[bot] 621816fb56
docs: update README.md [skip ci] 2021-01-06 15:54:33 +00:00
fmoko cfae54d361
Merge pull request from chrizel/patch-1
fix(threads1): line number correction
2021-01-06 16:54:16 +01:00
Christian Zeller 7857b0a689
fix(threads1): line number correction 2021-01-06 13:47:20 +01:00
Marius Ungureanu 10965920fb
fix(move_semantics4): Small readbility improvement ()
* Small readbility improvement move_semantics4 doc

* Remove `an` as it refers to the argument
2021-01-06 10:12:33 +01:00
fmoko d2e7ecabd8
Merge pull request from rust-lang/all-contributors/add-wsh
docs: add wsh as a contributor
2021-01-04 14:12:24 +01:00
fmoko 5772589dc3
Merge pull request from wsh/docfixes
docs: mention flatten in the options2 hint
2021-01-04 14:12:11 +01:00
allcontributors[bot] 6df08b411b
docs: update .all-contributorsrc [skip ci] 2021-01-04 13:12:11 +00:00
allcontributors[bot] c355ac6593
docs: update README.md [skip ci] 2021-01-04 13:12:10 +00:00
Will Hayworth e9b42bbc2a docs: mention flatten in the options2 hint 2021-01-03 03:42:39 -08:00
Abdou Seck 1283aa3bd8 Merge pull request from RoelofWobben/ghost-RoelofWobben-patch-1
fix: Update README.md for Windows users to exclude the rustlings directory
from the list of directories scanned by Anti-Virus programs.
2020-12-31 11:13:03 -05:00
RoelofWobben ff6cba7205 Update README.md 2020-12-31 10:57:37 -05:00
fmoko d0107f7921
Merge pull request from xehpuk/patch-1
fix: typo in default out text
2020-12-31 16:12:13 +01:00
xehpuk 644c49f1e0
fix: typo in default out text 2020-12-30 22:56:04 +01:00
mokou a303d508cf release: 4.3.0 2020-12-29 11:39:26 +01:00
mokou 44d39112ff feat: Rewrite default out text
This has been in place for a long time now, before we had an install
script, so it ended up repeating a bunch of the same things that the
install script does automatically. I rewrote it so that it gives more
helpful information about how you're supposed to do Rustlings.
Hopefully this will reduce the number of "I started Rustlings and it
gave me an error" issues (no offense to anyone who opened one of those,
it was pretty unclear that it _wasn't_ an error).
2020-12-29 11:34:52 +01:00
mokou 28020d0c54 docs: Add note on uninstalling to README 2020-12-29 11:23:08 +01:00
Axel Viala 0ef95947cc
fix(functions2): Change signature to trigger precise error message: ()
Now trigger this error:
```
error: expected type, found `)`
  --> exercises/functions/functions2.rs:10:16
   |
10 | fn call_me(num:) {
   |                ^ expected type

```
2020-12-27 12:36:38 +01:00
allcontributors[bot] 4ac70a99ae
docs: add seancad as a contributor
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2020-12-15 08:33:47 +01:00
seancad bcf14cf677
fix: update structs README 2020-12-15 08:32:46 +01:00
fmoko 1dae782cd4
Merge pull request from JuliaCao/update_exec_order
fix: added missing exercises to info.toml
2020-12-13 02:30:57 +01:00
JuliaCao 90cfb6ff28 fix: added missing exercises to info.toml 2020-12-12 10:34:59 -08:00
allcontributors[bot] 26110da7ca
docs: add pcn as a contributor
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2020-12-08 10:12:57 +01:00
Peter N 30644c9a06
fix: gives a bit more context to magic number 2020-12-08 10:08:25 +01:00
JuliaCao 033bf1198f
feat: match exercise order to book chapters ()
Added exercise to book chapter mapping table to exercise README
2020-12-07 15:37:19 +01:00
fmoko cdc7d92e57
Merge pull request from tinkhauser/vec1_bugfix
fix(vec1): Have test compare every element in a and v
2020-12-06 15:09:45 +01:00
fmoko af0e3b8f17
Merge pull request from xakon/fix/try_from_into
feat(try_from_into): remove duplicate annotation
2020-12-03 18:23:48 +01:00
Christos Kontas 04f1d079aa feat(try_from_into): remove duplicate annotation 2020-12-03 17:51:30 +01:00
Jacob Tinkhauser 9b6c629397
fix(vec1): Have test compare every element in a and v
The previous test would stop comparing elements in array a and vec v upon reaching the last element of either. This resulted in the test passing even if v did not contain all the elements in a. This change to the test fixes that bug and should only pass if all the elements in a and v are present and equal.
2020-11-29 01:35:14 +00:00
fmoko 5aa467bef2
Merge pull request from wh5a/bugfix
fix(try_from_into): type error
2020-11-12 16:36:50 +01:00
fmoko af7ad27f89
chore: Remove buildkite build file 2020-11-12 09:50:55 +01:00
fmoko d6d57bfbb8
docs: Remove buildkite badge from README 2020-11-12 09:50:39 +01:00
Wei Hu 4f4cfcf3c3 fix(try_from_into): type error 2020-11-11 21:02:00 -08:00
Brock fa9f522b7f
feat: Crab? ()
Crab?
2020-11-11 23:06:14 +01:00
Caleb Webber 838f9f3008
feat: add "rustlings list" command 2020-11-10 18:36:19 +01:00
JP 96347df9df
fix(try_from_into): Update description ()
Description update
2020-11-08 19:30:40 +01:00
Brock 9334783da3
fix(structs1): Adjust wording ()
Co-authored-by: fmoko <mokou@posteo.de>
2020-11-08 10:31:45 +01:00
mokou 964b2a331d release: 4.2.0 2020-11-07 14:21:10 +01:00
fiplox 95ccd92616
feat(try_from_into): Add tests ()
Co-authored-by: Volodymyr Patuta <6977238-fiplox@users.noreply.gitlab.com>
2020-11-07 14:01:39 +01:00
JP 197d3a3d89
fix(iterators2): Update description ()
grammar fix in the description
2020-11-07 13:54:14 +01:00
fmoko a7ddd747ca
Merge pull request from seeplusplus/inotify-watch-error
fix: log error output when inotify limit is exceeded
2020-11-07 13:53:35 +01:00
Caleb Webber d61b4e5a13
fix: log error output when inotify limit is exceeded
closes 
2020-11-05 19:30:50 -05:00
allcontributors[bot] 68e646f8aa
docs: add seeplusplus as a contributor 2020-11-05 10:03:43 +01:00
Caleb Webber 21bfb2d477
fix(installation): Update the MinRustVersion
closes #577df

Co-authored-by: Caleb Webber <seeplusplus@users.noreply.github.com>
2020-11-05 09:59:25 +01:00
fmoko a9dae71188
Merge pull request from jrvidal/temp_file
fix: more unique temp_file
2020-10-31 12:57:33 +01:00
fmoko dd84cc5fd4
Merge pull request from rust-lang/all-contributors/add-sazid 2020-10-30 20:29:47 +01:00
allcontributors[bot] 51631f4c2e
docs: update .all-contributorsrc [skip ci] 2020-10-30 19:29:37 +00:00
allcontributors[bot] 535a8c8243
docs: update README.md [skip ci] 2020-10-30 19:29:36 +00:00
fmoko 7abfbd23d0
Merge pull request from sazid/main 2020-10-30 20:28:46 +01:00
sazid 633c00cf80 feat: Add HashMap exercises 2020-10-31 01:11:04 +06:00
sazid 0c12fa31c5 feat: Add Vec exercises 2020-10-31 01:10:49 +06:00
Roberto Vidal 5643ef05bc fix: more unique temp_file 2020-10-30 14:39:28 +01:00
fmoko f38f42f17d
Merge pull request from notmatt/mbs-fixups 2020-10-14 17:22:49 +02:00
Matthew Smillie 472d8592d6 fix(primitive_types6): remove 'unused doc comment' warning 2020-10-13 23:20:17 -07:00
Matthew Smillie 4fb230daf1 fix(primitive_types6): missing comma in test 2020-10-13 23:18:41 -07:00
Rastamo e6bde22f9c
chore: primitive_types6 mode changed to test ()
primitive_types6 exercise was changed to test yesterday, but info.toml file wasn't updated.
I think this change should fix it.
2020-10-11 14:00:03 +02:00
allcontributors[bot] cc5b9b772a
docs: add AnnikaCodes as a contributor ()
Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
Co-authored-by: fmoko <mokou@posteo.de>
2020-10-10 17:08:22 +02:00
allcontributors[bot] ded1474bbb
docs: add darnuria as a contributor ()
Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2020-10-10 16:07:15 +02:00
Axel Viala 2b1fb2b739
feat(primitive_types6): Add a test ()
Co-authored-by: Annika <56906084+AnnikaCodes@users.noreply.github.com>
Co-authored-by: fmoko <mokou@posteo.de>
2020-10-10 16:04:19 +02:00
Ryan McQuen 18e0bfef1d
fix(quiz3): Second test is for odd numbers, not even. () 2020-10-10 13:11:57 +02:00
fmoko 3be760dc38
Merge pull request from rust-lang/all-contributors/add-ryanpcmcquen 2020-10-09 02:16:07 +02:00
allcontributors[bot] 29dd0b1e41
docs: update .all-contributorsrc [skip ci] 2020-10-09 00:15:54 +00:00
allcontributors[bot] e1fdfbb062
docs: update README.md [skip ci] 2020-10-09 00:15:53 +00:00
mokou 89c07b5e43 release: 4.1.0 2020-10-05 18:42:26 +02:00
fmoko 9b5350eab1
Merge pull request from jienius/doc-improve-readme
docs: Fix grammatical errors in Readme
2020-10-02 12:52:34 +02:00
jieniu$ 5382cd696a docs: Fix grammatical errors in Readme 2020-10-01 20:15:36 -06:00
fmoko 69fc9ce10e
Merge pull request from YJDoc2/main 2020-10-01 12:17:05 +02:00
Yashodhan Joshi 13ac6f38dc Merge branch 'master' of https://github.com/YJDoc2/rustlings 2020-10-01 08:34:01 +05:30
Yashodhan Joshi 2ec0bdfd99 fix(variables5) : make shadowing more prominent
closes 
2020-10-01 08:31:42 +05:30
Alexx Roche c03e1e6c6c
chore: fixed test name 2020-09-27 21:57:51 +02:00
fmoko 2a682abeef
Merge pull request from calvinbrown085/adding-test-for-false-case 2020-09-27 17:05:42 +02:00
allcontributors[bot] 9f38b54a2d
docs: add greg-el as a contributor
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2020-09-25 13:43:01 +02:00
Greg Leonard 2933f51949
chore: Change point to comma in from_into.rs
A typo in the fn test_bad_age() hint message had a point rather than comma

Prev:
// Test that "Mark.twenty"

Current:
// Test that "Mark,twenty"
2020-09-25 13:39:52 +02:00
fmoko a75300b8c7
Merge pull request from rust-lang/all-contributors/add-dev-cyprium 2020-09-22 11:31:53 +02:00
allcontributors[bot] 01f4bb86c3
docs: update .all-contributorsrc [skip ci] 2020-09-22 09:31:42 +00:00
allcontributors[bot] 79c3ada49b
docs: update README.md [skip ci] 2020-09-22 09:31:41 +00:00
fmoko ac276d06fa
Merge pull request from rust-lang/all-contributors/add-GaurangTandon 2020-09-22 11:04:45 +02:00
allcontributors[bot] c7eabe61bb
docs: update .all-contributorsrc [skip ci] 2020-09-22 09:04:33 +00:00
allcontributors[bot] 8f28bcf704
docs: update README.md [skip ci] 2020-09-22 09:04:32 +00:00
fmoko be3b289a10
Merge pull request from rust-lang/all-contributors/add-jmahmood 2020-09-22 10:57:44 +02:00
allcontributors[bot] 19a0c1f3cb
docs: update .all-contributorsrc [skip ci] 2020-09-22 08:57:33 +00:00
allcontributors[bot] dc94fcc6e8
docs: update README.md [skip ci] 2020-09-22 08:57:32 +00:00
fmoko 183237c858
Merge pull request from rust-lang/all-contributors/add-EvanCarroll 2020-09-22 10:56:28 +02:00
allcontributors[bot] 599a44f90f
docs: update .all-contributorsrc [skip ci] 2020-09-22 08:56:18 +00:00
allcontributors[bot] 08e9c7aa2f
docs: update README.md [skip ci] 2020-09-22 08:56:17 +00:00
fmoko a893d04e81
Merge pull request from rust-lang/all-contributors/add-siobhanjacobson 2020-09-22 10:55:09 +02:00
allcontributors[bot] 5996bd57ea
docs: update .all-contributorsrc [skip ci] 2020-09-22 08:54:54 +00:00
allcontributors[bot] 909b297ae3
docs: update README.md [skip ci] 2020-09-22 08:54:53 +00:00
fmoko abdc3b2211
Merge pull request from rust-lang/all-contributors/add-wrobstory 2020-09-22 10:52:39 +02:00
allcontributors[bot] e66d2085b7
docs: update .all-contributorsrc [skip ci] 2020-09-22 08:52:29 +00:00
allcontributors[bot] 4a5e48e88f
docs: update README.md [skip ci] 2020-09-22 08:52:28 +00:00
fmoko 3a586a0c19
Merge pull request from rust-lang/all-contributors/add-DiD92 2020-09-22 10:51:01 +02:00
allcontributors[bot] 144dec3fd3
docs: update .all-contributorsrc [skip ci] 2020-09-22 08:50:51 +00:00
allcontributors[bot] 448d116a89
docs: update README.md [skip ci] 2020-09-22 08:50:50 +00:00
fmoko 8493e5d09f
Merge pull request from rust-lang/all-contributors/add-apatniv 2020-09-22 10:50:07 +02:00
allcontributors[bot] 83e7365fd8
docs: update .all-contributorsrc [skip ci] 2020-09-22 08:49:57 +00:00
allcontributors[bot] b6040e6061
docs: update README.md [skip ci] 2020-09-22 08:49:56 +00:00
fmoko 858b9a5119
Merge pull request from rust-lang/all-contributors/add-bertonha 2020-09-22 10:48:48 +02:00
allcontributors[bot] 00fbcd14f7
docs: update .all-contributorsrc [skip ci] 2020-09-22 08:48:39 +00:00
allcontributors[bot] 062f18d353
docs: update README.md [skip ci] 2020-09-22 08:48:38 +00:00
fmoko 58760bce54
Merge pull request from rust-lang/all-contributors/add-jihchi 2020-09-22 10:45:07 +02:00
allcontributors[bot] ca4f026074
docs: update .all-contributorsrc [skip ci] 2020-09-22 08:44:57 +00:00
allcontributors[bot] f285ac2281
docs: update README.md [skip ci] 2020-09-22 08:44:56 +00:00
fmoko 0f3db4dbb9
Merge pull request from rust-lang/all-contributors/add-Darrenmeehan 2020-09-22 10:43:33 +02:00
allcontributors[bot] 18b2d451cd
docs: update .all-contributorsrc [skip ci] 2020-09-22 08:43:24 +00:00
allcontributors[bot] b6dd1af7d2
docs: update README.md [skip ci] 2020-09-22 08:43:23 +00:00
fmoko 303c8ee7cd
Merge pull request from rust-lang/all-contributors/add-avrong 2020-09-22 10:40:56 +02:00
allcontributors[bot] 98d6b15fc0
docs: update .all-contributorsrc [skip ci] 2020-09-22 08:40:46 +00:00
allcontributors[bot] 77f407dd5f
docs: update README.md [skip ci] 2020-09-22 08:40:45 +00:00
fmoko a12a3ef08b
Merge pull request from rust-lang/all-contributors/add-lebedevsergey 2020-09-22 10:39:10 +02:00
allcontributors[bot] 6480fcaf7c
docs: update .all-contributorsrc [skip ci] 2020-09-22 08:39:00 +00:00
allcontributors[bot] f5cb439fe6
docs: update README.md [skip ci] 2020-09-22 08:38:59 +00:00
fmoko 15c9e85690
Merge pull request from rust-lang/all-contributors/add-uce 2020-09-22 10:37:34 +02:00
allcontributors[bot] 8f8a85303b
docs: update .all-contributorsrc [skip ci] 2020-09-22 08:36:53 +00:00
allcontributors[bot] 114cc2db21
docs: update README.md [skip ci] 2020-09-22 08:36:52 +00:00
Calvin Brown bec97b6c76
Fixing test3 to have enough tests to make sure we test all cases 2020-09-21 15:23:19 -05:00
Jannek Squar 114b54cbdb
fix(structs3): Small adjustment of variable name
Co-authored-by: Jannek <squar@informatik.uni-hamburg.de>
2020-09-19 21:22:56 +02:00
fmoko 0f16463794
Merge pull request from mukundbhudia/iterators1 2020-09-18 15:23:28 +02:00
Mukund Bhudia 8ff5fde88e
Update info.toml for typo fix
Co-authored-by: Andrew Marquez <andy2mgcc@gmail.com>
2020-09-18 10:40:11 +01:00
Ryan McQuen 3286c5ec19
fix(using_as): Add test so that proper type is returned. () 2020-09-07 19:09:27 +02:00
Koalab99 ee7cdc66b3
chore: Removed extra whitespaces
Co-authored-by: Corentin ARNOULD <corentin.arn@gmail.com>
2020-08-27 19:51:19 +02:00
fmoko 9699da4968
Merge pull request from bhgsbatista/patch-1
Make macros4 not compile by default
2020-08-27 11:21:09 +02:00
Samuel Batista 6bb0b48b10
Make macros4 not compile by default
Did you mean this? I'm new to rust and this test passed right away, so unsure what the intention was.
2020-08-26 22:17:03 -04:00
fmoko 70da09eae2
Merge pull request from Ant0wan/quiz2_markers
fix(exercises): adding question mark to quiz2
2020-08-25 21:05:16 +02:00
Antoine Barthelemy 101072ab9f fix(exercises): adding question mark to quiz2
Question marks added for consistency.

closes 
2020-08-25 16:38:41 +02:00
fmoko 47f7672c03
fix(generics3): clarify grade change 2020-08-25 10:45:12 +02:00
John Heath dd54ccf677
Make comments on example clearer
I actually struggled because I overlooked the fact that I needed to change the 2.1 to "A+". 

So I wanted to make things clearer for future rustlings.
2020-08-24 22:37:31 +01:00
fmoko 66ec916b3d
Merge pull request from seeplusplus/main
fix(arc1): index mod should equal thread count
2020-08-17 12:48:41 +02:00
seeplusplus b4062ef699 fix(arc1): index mod should equal thread count 2020-08-16 20:55:50 -04:00
fmoko 2d3816341e
Merge pull request from etiennebarrie/rustfmt-on-exercises
chore: Run rustfmt on exercises
2020-08-10 17:33:55 +02:00
fmoko d1054cd596
Merge pull request from etiennebarrie/cargo-fmt
chore: Run cargo fmt
2020-08-10 17:33:22 +02:00
Étienne Barrié 81f8c2f83c chore: Run cargo fmt 2020-08-10 10:42:54 -04:00
Étienne Barrié 3144d3ae63 chore: Run rustfmt on exercises 2020-08-10 10:24:21 -04:00
Mukund Bhudia 9642f5a3f6 feat: Added iterators1.rs exercise 2020-08-04 12:57:01 +01:00
fmoko c4853ee6bb
Merge pull request from dmarcoux/update-rustlings-in-cargo-lock 2020-08-04 01:57:04 +02:00
Dany Marcoux 1cc40bc9ce
fix: Update rustlings version in Cargo.lock 2020-08-03 22:17:32 +02:00
Robby 38a615f407
chore: add .vscode to gitignore 2020-07-24 13:23:01 +02:00
Adi Vaknin 4f2468e14f
feat(cli): Added 'cls' command to 'watch' mode () 2020-07-23 20:23:27 +02:00
Ryan McQuen 8f7b5bd00e
feat: Add ability to run rustlings on repl.it ()
Co-authored-by: fmoko <mokou@posteo.de>
2020-07-23 19:21:15 +02:00
Ryan McQuen 4821a8be94
feat: Add gitpod support () 2020-07-23 19:20:21 +02:00
Chad Dougherty 523d18b873
feat(try_from_into): Add insufficient length test () 2020-07-13 11:39:05 +02:00
Eli Blaney c52be7dfcb
docs: Add uninstall info to README.md
* docs: Add uninstall info to README.md
* docs: Format commands as bash block
2020-07-12 08:44:11 +01:00
fmoko c2bfcf1c54
Merge pull request from benjaminfjones/fix/exercise_whitespace
chore: change exercise whitespace for consistency
2020-07-11 23:12:58 +02:00
Benjamin Jones bb5f404e35 chore: Alter whitespace for consistency
* Add newline after "I AM DONE" in exercises for consistency
* Remove trailing whitespace from exercises
2020-07-11 11:50:54 -07:00
Philip Pokarowski 106dbbc341
Update README.md () 2020-07-09 09:25:50 +02:00
DEWA Kazuyuki/出羽和之 4b6540c71a
fix(enums3): Update Message::ChangeColor to take a tuple. () 2020-07-08 11:56:43 +02:00
Alexx Roche 816b1f5e85 feat: Remind the user of the hint option ()
Suggestion from AbdouSeck https://github.com/rust-lang/rustlings/issues/424#issuecomment-639870331
for when the student's code has errors.
2020-07-08 11:52:23 +02:00
Alexx Roche 9f61db5dbe
feat: Remind the user of the hint option ()
Suggestion from AbdouSeck https://github.com/rust-lang/rustlings/issues/424#issuecomment-639870331
for when the student's code has errors.
2020-07-08 11:51:12 +02:00
mokou e823bef970 docs: Add missing closing brackets to changelog 2020-07-08 11:43:08 +02:00
mokou f9ccc6a289 release: 4.0.0 2020-07-08 11:35:27 +02:00
fmoko b32a666541
Merge pull request from Sowed/main 2020-07-01 10:19:45 +02:00
iamcastelli b636825de3
Merge pull request from Sowed/then-to-than-docs-patch
fix: Change then to than
2020-06-27 16:49:39 +04:00
iamcastelli ddd98ad75d
fix: Change then to than
`than` makes more grammatical sense than `then` in this context.
2020-06-27 15:58:53 +04:00
mokou d355927024 Merge remote-tracking branch 'origin/master' into main 2020-06-22 04:47:27 +02:00
fmoko 75c0053bb1
Merge pull request from
fix : Use of integer for prices, therefore also for weight
2020-06-22 00:09:09 +02:00
mokou 55a9284665 chore: Move from master branch to main branch 2020-06-14 14:48:51 +02:00
Alexx Roche 113cdae2d4
fix(arc1): Passively introduce attributes ()
Ensure that std::sync::Arc is actually used, as this exercise can be compiled using things already learnt in previous exercises.
2020-06-14 12:15:35 +02:00
fmoko c6295ade33
Merge pull request from millefalcon/master
Added example with `String` to show the AsRef working
2020-06-13 22:15:57 +02:00
fmoko e1e453075f
Merge pull request from AbdouSeck/show-tests-prints 2020-06-12 23:04:51 +02:00
Sebastien Caunes 9ca08b8f2b fix : Use of integer for prices, therefore also for weight
rename confusing "from" and "to" to sender_country and recipient_country as suggested
2020-06-11 11:44:47 -05:00
tim bangma f47d3f422d
docs: Update Invoke-WebRequest to Start-BitsTransfer () 2020-06-10 10:51:03 +02:00
Alexx Roche e6bd8021d9
fix(generics2): Guide students to the answer () 2020-06-09 13:54:18 +02:00
millefalcon 307252e9ae Added example to show the AsRef working 2020-06-08 07:51:34 -04:00
Alexx Roche bb2ca25110
fix(box1): fix comment typo ()
Doesn't effect the code.
2020-06-06 12:07:39 +02:00
Abdou Seck 9e4fb1009f fix(installation): Provide a backup git reference when tag can't be curl
closes 

If the parsed JSON data curled during a bash installation is not valid, use the repository's tag files
as a backup. If those files don't exist somehow, then checkout the master branch and install it.
2020-06-05 16:33:14 -04:00
Abdou Seck 8ad5f9bf53 feat: Add a --nocapture option to display test harnesses' outputs
This new feature can be accessed by invoking rustlings with --nocapture.

Both unit and integration tests added.

closes 

BREAKING CHANGES:
The following function take a new boolean argument:
	* `run`
	* `verify`
	* `test`
	* `compile_and_test`
2020-06-04 11:18:26 -04:00
Abdou Seck 02a2fe4871 Collapse nested if statements 2020-06-04 11:18:09 -04:00
Abdou Seck 40741c5b0b Use .to_string rather than format macro 2020-06-03 17:18:48 -04:00
Alexx Roche 0dd1c6ca6b
fix: rename quiz1 to tests1 in info ()
`rustlings run tests1` wasn't working because of this typo.
2020-06-03 20:07:06 +02:00
Alexx Roche 5563adbb89
fix: fix quiz naming inconsistency ()
Inconsistent naming when compared with the other quiz files.
2020-06-03 20:06:35 +02:00
Alexx Roche 524e17df10
fix(variables6): minor typo ()
Looks like this was cloned from variables5.rs
2020-06-03 13:34:43 +02:00
fmoko 73e848e96f
Merge pull request from danwilhelm/traits-readme
feat: Add traits README
2020-05-30 17:58:31 +02:00
fmoko 5f0806967c
Merge pull request from AlexandruGG/feature/box-exercise 2020-05-30 17:58:16 +02:00
Dan Wilhelm 173bb14140 feat: Add traits README 2020-05-28 20:21:33 -07:00
fmoko 918f310674
Merge pull request from tsauvajon/fix-option1
fix(option1): Don't add only zeros to the numbers array
2020-05-29 00:33:00 +02:00
fmoko a75fdbd8ad
Merge pull request from danwilhelm/powershell-correction
chore: Fix PowerShell capitalization
2020-05-29 00:32:45 +02:00
Dan Wilhelm 9d3f189b0e chore: Fix PowerShell capitalization 2020-05-28 14:51:20 -07:00
AlexandruGG 7e79c51222 Add .idea to gitignore 2020-05-28 18:01:32 +01:00
fmoko a180d831a1
Merge pull request from danwilhelm/generics3-90chars 2020-05-28 10:15:55 +02:00
Dan Wilhelm e81adc2752
chore: Add Powershell reminder 2020-05-28 09:35:29 +02:00
Allan Soares Duarte 500422d594
chore: Update variables6.rs book link 2020-05-28 09:33:15 +02:00
Dan Wilhelm 0311c03735 chore: Limit generics3 lines to 90 chars 2020-05-27 23:39:11 -07:00
AlexandruGG df81141d6f Address PR feedback: add tests 2020-05-27 10:03:59 +01:00
Thomas Sauvajon cce6a44277
fix(option1): Don't add only zeros to the numbers array 2020-05-27 18:55:12 +10:00
AlexandruGG 7479a4737b feat: Add box1.rs exercise 2020-05-26 21:46:24 +01:00
Evan Carroll 06ef4cc654
fix: confine the user further in variable exercises
We want to teach a specific lesson. To ensure that we do, let's try to
provide more clarity on what the user should not do.
2020-05-25 10:09:11 +02:00
Jade McGough c7c3130507
chore: remove struct2 hint comment 2020-05-20 08:31:28 +02:00
Sanjay K 010a045692
feat: renames test to quiz, fixes
BREAKING CHANGE

* changed test to quiz: fixes issues in 
* fixed info.toml: 
* fixed naming related issues
2020-05-19 18:47:44 +02:00
fmoko 51666609f1
Merge pull request from sjmann/generics-2-fix 2020-05-19 17:49:55 +02:00
Stefan Kupresak 10967bce57
fix(option2): Add TODO to comments () 2020-05-16 22:48:18 +02:00
IkaR49 763aa6e378
feat: Rewrite try_from_into () 2020-05-15 23:02:57 +02:00
Gaurang Tandon d6c0a688e6
fix(test2): name of type String and &str () 2020-05-13 12:38:14 +02:00
Jawaad Mahmood 9f75554f2a
fix(options1): Add hint about Array Initialization () 2020-05-10 13:21:29 +02:00
Evan Carroll 2b20c8a0f5
fix(errorsn): Try harder to confine the user. () 2020-05-06 21:12:15 +02:00
fmoko 1b4590b42b
Merge pull request from siobhanjacobson/fix-enums3-test 2020-05-05 19:50:28 +02:00
Siobhan Jacobson 09e89bbcd3 Update Message::Move in the enums3 test to take a Point. 2020-05-04 18:59:23 -04:00
fmoko 7c4b1f910c
Merge pull request from DiD92/exercise_structs3 2020-05-03 19:44:26 +02:00
fmoko 3ceabe91f8
Merge pull request from wrobstory/wrobstory-exercises 2020-05-03 19:44:08 +02:00
fmoko a39ffb2fb8
Merge pull request from apatniv/update_test_case 2020-05-03 13:31:46 +02:00
apatniv 41f989135d Review Comments: Add other test cases 2020-05-02 20:41:11 -04:00
Rob Story f6cffc7e48 fix(option1): Add cast to usize, as it is confusing in the context of an exercise about Option 2020-05-02 16:39:37 -07:00
Rob Story 1da84b5f7c feat: Add if2 exercise 2020-05-02 13:02:16 -07:00
fmoko ebfe76cdb6
Merge pull request from bertonha/deprecated-description 2020-05-02 18:38:32 +02:00
Christofer Bertonha c301814d68 chore: Remove deprecated description from error_handling/errorsn.rs 2020-05-02 18:30:11 +02:00
fmoko 09478571df
Merge pull request from Darrenmeehan/patch-2 2020-04-30 18:33:46 +02:00
Jihchi Lee a901499ede
fix(from_into.rs): typo 2020-04-30 15:53:50 +02:00
fmoko de65026db0
Merge pull request from danwilhelm/dw-typos 2020-04-30 09:21:42 +02:00
fmoko 071b51d588
Check if python is available while checking for git, rustc and cargo () 2020-04-30 09:21:17 +02:00
Darren Meehan 80390d8a03
docs: Remove outdated MacOS instructions
The quoted file no longer exists
2020-04-30 08:13:41 +01:00
Dan Wilhelm 9590082848 fix: update iterator and macro text for typos and clarity
- /macros/README.md: Typo "modules" => "macros"
- iterators2.py: Reduce line length to <90-char width.
- iterators4.py: Update 'fun' => 'challenge' as per PR#177
- rustlings hint iterators4: improve clarity
2020-04-29 19:11:54 -07:00
Abdou Seck 9cfb617d5b fix(installation): Check if python is available while checking for git,rustc and cargo
closes 
2020-04-29 15:11:05 -04:00
Dídac Sementé Fernández b66e2e0962 feat: Added exercise structs3.rs 2020-04-27 20:26:34 +02:00
Aleksei Trifonov 32721bbc83
chore: fix missing space in the hint for errorsn.rs 2020-04-25 10:25:41 +02:00
apatniv 19fb1c240c test: Add missing test case for from_str exercise 2020-04-21 22:51:56 -04:00
Steven Mann 630ff0e00b
chore: add explanatory comment to clippy1 2020-04-21 18:50:00 +02:00
sjmann 964c974a02 fix: update generics2 closes 2020-04-21 13:34:25 +01:00
lebedevsergey c9e4f2cfb4
fix: confusing comment in conversions/try_from_into.rs
Co-authored-by: Lebedev <sergey.lebedev@corp.mail.ru>
2020-04-17 15:43:01 +02:00
Said Aspen a3a554aeed
Hints for structs1 and structs2 () 2020-04-16 16:21:36 +02:00
Ufuk Celebi 6c3cc2caf5
chore: delete orphaned error_handling/option1.rs
`error_handling/option1.rs` has been replaced by `option/option1.rs` and
is not referenced in `info.toml` any more.
2020-04-15 23:52:31 +02:00
Said Aspen 5999acd24a
feat: Add exercise variables6 covering const () 2020-04-14 10:13:20 +02:00
allcontributors[bot] 59f56b24d9
docs: add saidaspen as a contributor ()
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2020-04-14 10:12:51 +02:00
Saurav abd0ec379c
chore: update variables5.rs book link ()
chore: update variables5.rs book link

chore: update variables5.rs book link
2020-04-12 19:35:20 +02:00
fmoko cfb98a5617
docs: remove now obsolete credits section 2020-04-12 01:03:28 +02:00
allcontributors[bot] fafcffed25
docs: add crodjer as a contributor ()
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2020-04-12 01:00:22 +02:00
allcontributors[bot] 3f1209ce19
docs: add sanjaykdragon as a contributor ()
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2020-04-12 00:59:07 +02:00
allcontributors[bot] b217961254
docs: add sl4m as a contributor ()
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2020-04-12 00:57:55 +02:00
allcontributors[bot] cd06b39a42
docs: add Tarnadas as a contributor ()
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2020-04-12 00:57:18 +02:00
allcontributors[bot] 84e1f85be2
docs: add sjmann as a contributor ()
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2020-04-12 00:56:40 +02:00
allcontributors[bot] f060f099d4
docs: add pbx as a contributor ()
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2020-04-12 00:55:30 +02:00
allcontributors[bot] e093af4c05
docs: add TorbenJ as a contributor ()
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2020-04-12 00:54:59 +02:00
allcontributors[bot] eface5ef45
docs: add harrisonmetz as a contributor ()
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2020-04-12 00:54:28 +02:00
allcontributors[bot] 5b72f478a7
docs: add gnodarse as a contributor ()
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2020-04-12 00:53:46 +02:00
allcontributors[bot] 5f5a0465cb
docs: add codehearts as a contributor ()
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
Co-authored-by: fmoko <mokou@posteo.de>
2020-04-12 00:52:51 +02:00
allcontributors[bot] f509e479a1
docs: add Socratides as a contributor ()
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2020-04-12 00:51:02 +02:00
allcontributors[bot] ad00c2cf51
docs: add AbdouSeck as a contributor ()
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2020-04-12 00:49:57 +02:00
allcontributors[bot] a20f80623e
docs: add rahatarmanahmed as a contributor ()
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2020-04-12 00:49:05 +02:00
allcontributors[bot] f26dca6d8e
docs: add jensim as a contributor ()
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2020-04-12 00:48:12 +02:00
fmoko 9ea089a5d9
docs: bump contributors per line down to 8 2020-04-12 00:47:24 +02:00
allcontributors[bot] f07d1c9488
docs: add jrvidal as a contributor ()
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2020-04-12 00:46:29 +02:00
allcontributors[bot] 0d0c79a5cb
docs: add WofWca as a contributor ()
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2020-04-12 00:45:01 +02:00
allcontributors[bot] 9bb5aa583f
docs: add workingjubilee as a contributor ()
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2020-04-12 00:44:27 +02:00
allcontributors[bot] f26ed591f3
docs: add nyxtom as a contributor ()
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2020-04-12 00:43:54 +02:00
allcontributors[bot] 0b4576a028
docs: add gdoenlen as a contributor ()
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2020-04-12 00:43:08 +02:00
allcontributors[bot] d7bb220ba3
docs: add vyaslav as a contributor ()
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2020-04-12 00:42:30 +02:00
allcontributors[bot] f907c710b2
docs: add Dylnuge as a contributor ()
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2020-04-12 00:41:21 +02:00
allcontributors[bot] c6bcb319f8
docs: add ajaxm as a contributor ()
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2020-04-12 00:40:26 +02:00
allcontributors[bot] 443600194c
docs: add nkanderson as a contributor ()
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2020-04-12 00:39:56 +02:00
allcontributors[bot] 7b6f14c25a
docs: add petemcfarlane as a contributor ()
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2020-04-12 00:39:14 +02:00
allcontributors[bot] 887d919323
docs: add MrFroop as a contributor ()
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2020-04-12 00:38:25 +02:00
allcontributors[bot] 74d32f0cca
docs: add Jesse-Cameron as a contributor ()
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2020-04-12 00:37:45 +02:00
allcontributors[bot] 3f479be7e7
docs: add danwilhelm as a contributor ()
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2020-04-12 00:36:55 +02:00
allcontributors[bot] 95d02a23d0
docs: add miller-time as a contributor ()
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2020-04-12 00:35:42 +02:00
allcontributors[bot] 8b59b9852f
docs: add briankung as a contributor ()
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2020-04-12 00:34:41 +02:00
allcontributors[bot] 53bda94f77
docs: add eddyp as a contributor ()
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2020-04-12 00:34:06 +02:00
allcontributors[bot] 52580cfd0d
docs: add dendi239 as a contributor ()
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2020-04-12 00:32:56 +02:00
allcontributors[bot] cf3d5b44e6
docs: add yvan-sraka as a contributor ()
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2020-04-12 00:32:07 +02:00
allcontributors[bot] 491dc2e5ca
docs: add cjpearce as a contributor ()
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2020-04-12 00:31:21 +02:00
allcontributors[bot] b89cdef120
docs: add mgeier as a contributor ()
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2020-04-12 00:30:31 +02:00
allcontributors[bot] 348fe339b9
docs: add zacanger as a contributor ()
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2020-04-12 00:28:52 +02:00
fmoko e79d7ea981
docs: increase contributors per line 2020-04-12 00:28:06 +02:00
allcontributors[bot] e7841ba2ed
docs: add ColinPitrat as a contributor ()
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2020-04-12 00:27:26 +02:00
allcontributors[bot] 37687e9323
docs: add kisom as a contributor ()
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2020-04-12 00:24:27 +02:00
allcontributors[bot] b749314944
docs: add abagshaw as a contributor ()
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2020-04-12 00:23:18 +02:00
allcontributors[bot] 3eb0fb5aa6
docs: add shaunbennett as a contributor ()
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2020-04-12 00:22:30 +02:00
allcontributors[bot] 44a4cf3b27
docs: add Delet0r as a contributor ()
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2020-04-12 00:21:37 +02:00
allcontributors[bot] 9a8762ba6e
docs: add evestera as a contributor ()
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2020-04-12 00:21:03 +02:00
allcontributors[bot] 2e1bd5ef4e
docs: add lukabavdaz as a contributor ()
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2020-04-12 00:20:06 +02:00
allcontributors[bot] a9dc101701
docs: add spacekookie as a contributor ()
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2020-04-12 00:18:53 +02:00
allcontributors[bot] e2835de137
docs: add hynek as a contributor ()
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2020-04-12 00:17:40 +02:00
allcontributors[bot] 535e7a6a28
docs: add robertlugg as a contributor ()
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2020-04-12 00:16:50 +02:00
allcontributors[bot] fe96de2e2d
docs: add QuietMisdreavus as a contributor ()
* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2020-04-12 00:14:45 +02:00
allcontributors[bot] 9fd881443f
docs: add carols10cents as a contributor ()
* docs: update README.md [skip ci]

* docs: create .all-contributorsrc [skip ci]

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
2020-04-12 00:09:23 +02:00
mokou 2ff3f7ae13 3.0.0 2020-04-12 00:01:08 +02:00
fmoko 2b80f6ed41
chore: Remove duplicate option1 exercise 2020-04-11 17:27:10 +02:00
Rohan Jain 3ab084a421 fix(run): compile clippy exercise files
Additionally to running clippy, also compile the exercise file so that
`rustling run clippy1` works after a successful completion of the
exercise.

closes 

Signed-off-by: Rohan Jain <crodjer@gmail.com>
2020-04-11 08:58:23 +02:00
mokou 495174ff7c chore: remove travis ci
And add a buildkite build status badge
2020-04-08 12:27:28 +02:00
mokou b049fa2c84 feat(ci): add buildkite config 2020-04-08 12:08:37 +02:00
fmoko 052f0aa7d4
Merge pull request from Tuxified/patch-1
Remove duplicate not done comment
2020-04-08 11:23:49 +02:00
Tonći Galić 60393999b8
remove bottom comment instead of top 2020-04-08 11:00:11 +02:00
Roberto Vidal b3a3351e8e
fix: revert primitive_types4 () 2020-04-08 10:42:35 +02:00
Sanjay K 86b5c08b9b
feat: Add Option2 exercise ()
* added option2

* changed up the exercise, modified the help section

* Update exercises/option/option2.rs

Co-Authored-By: fmoko <mokou@posteo.net>

* Update exercises/option/option2.rs

Co-Authored-By: fmoko <mokou@posteo.net>

* Update exercises/option/option2.rs

Co-Authored-By: fmoko <mokou@posteo.net>

Co-authored-by: fmoko <mokou@posteo.net>
2020-04-07 20:16:10 +02:00
Tonći Galić dab90f7b91
Remove duplicate not done comment
As indicated in  , I found it confusing to have 2 comments as the code wouldn't compile unless I solved both issues (I used the script from  to remove a comment and use `:wn` to go to next exercise, hence this tripped me).
2020-04-07 17:00:45 +02:00
fmoko 71d31256a6
Merge pull request from jrvidal/output-mode
feature: adds "output" mode, resolves 
2020-04-07 11:26:48 +02:00
Roberto Vidal 3b6d5c3aaa feature: makes "compile" exercise print output, resolves
When running "compile"-mode exercises in interactive `verify` mode,
we print their output when we prompt the learner if they want to
continue. This improves the "experimentation" experience, since
trying different things does produce a visible change.
2020-04-06 16:17:14 +02:00
fmoko 7ce42941ea
Merge pull request from sanjaykdragon/master
feat: added option exercise
2020-04-05 15:58:09 +02:00
Sanjay K 3f8171475c updated info.toml 2020-04-05 09:45:07 -04:00
fmoko b135b589e0
Merge pull request from sjmann/generics-exercises
feat: added generics exercises
2020-04-05 14:40:34 +02:00
Sanjay K 05ca3d77f7 Merge branch 'master' of https://github.com/sanjaykdragon/rustlings 2020-04-02 08:41:14 -04:00
Sanjay K 6deee7e3e9 fixed spacing 2020-04-02 08:40:59 -04:00
fmoko 9dc404077a
Merge pull request from vjousse/fix-traits-doc
chore(TRAITS1): don't hardcode documentation version
2020-03-26 21:16:52 +01:00
Vincent Jousse 30e6af6069 Don't hardcode documentation version for traits 2020-03-26 15:22:22 +01:00
Sanjay K 9788496a85
Update option1.rs 2020-03-11 13:44:41 -04:00
Sanjay K 6d3a412d47
Update option1.rs 2020-03-11 13:44:10 -04:00
bors 700b236f4d Auto merge of - sl4m:update-from-into-ex, r=fmoko
Adds additional test to meet exercise rules

This PR adds an additional test to meet this exercise [rule](https://github.com/rust-lang/rustlings/blob/master/exercises/conversions/from_into.rs#L33).
2020-03-11 15:06:23 +00:00
skim bc22ec382f
adds additional test to meet exercise rules 2020-03-11 07:58:04 -07:00
Sanjay K 135e5d47a7 feat: added excercise for option 2020-03-05 15:52:54 -05:00
sjmann 0f8001ea44 add I AM NOT DONE comments 2020-02-28 00:31:55 +00:00
sjmann 5b6e23c323 removed artifact from manual testing 2020-02-28 00:29:30 +00:00
sjmann 29b30ec946 Merge branch 'master' of https://github.com/sjmann/rustlings into generics-exercises 2020-02-28 00:19:45 +00:00
sjmann 76be5e4e99 feat: added new exercises for generics 2020-02-28 00:09:08 +00:00
mokou 8b9479071c 2.2.1 2020-02-27 19:22:55 +01:00
mokou 3d9b03c52b fix: Re-add cloning the repo to install scripts 2020-02-27 19:19:31 +01:00
bors a03d9655a8 Auto merge of - Tarnadas:master, r=fmoko
feat: Add clippy lints

This is a feature PR which adds the possiblity to create clippy exercises.

Clippy has many awesome linting rules, which can give a deeper understanding about the Rust programming language, therefor I made this PR.
2020-02-26 14:22:51 +00:00
Mario Reder 1e2fd9c92f feat: Add clippy lints
- adds a new 'clippy' category for exercises
- clippy exercises should throw no warnings
- install script now also installs clippy

is related to https://github.com/rust-lang/rust-clippy/issues/2604
2020-02-26 14:07:07 +01:00
bors 7e8530b21f Auto merge of - jrvidal:refactor, r=fmoko
refactor: exercise evaluation

After working a bit on , I realized that it'd be useful to first perform a minor refactor of exercise evaluation.

* Now we have standard methods to compile + execute that return `Result`s.
* Success/failure messages are standardized.
2020-02-26 11:48:01 +00:00
bors 98358597a9 Auto merge of - sjmann:update-ignore, r=fmoko
chore: update gitignore to ignore pdb files

Pr for issue 
2020-02-26 10:46:53 +00:00
sjmann 8064facbb8 chore: update gitignore to ignore pdb files 2020-02-26 10:43:13 +00:00
sjmann f981dcfde4 Merge branch 'master' of https://github.com/sjmann/rustlings 2020-02-26 10:38:50 +00:00
mokou 6eb62fa2ce 2.2.0 2020-02-25 23:00:19 +01:00
bors 78295ce92f Auto merge of - sjmann:master, r=fmoko
chore: fixed merge conflicts from traits exercises added by s-marios

I hope this doesn't step on any toes but I wanted to try the traits exercises from  so I updated them to match the new structure with hints included in info.toml
2020-02-25 21:27:39 +00:00
fmoko 358fb473cd
Merge pull request from stigjb-forks/testing-test4
Enable test for exercise test4
2020-02-25 14:25:22 +01:00
Stig Johan Berggren a45486f2d0
Add a second test case 2020-02-25 14:25:03 +01:00
Stig Johan Berggren 8b971ffab6
Enable test for exercise test4 2020-02-25 14:13:10 +01:00
Steven Mann dc84aacc65
remove confusing comment wording 2020-02-25 11:00:09 +00:00
sjmann bbf8922ef7 Merge remote-tracking branch 'upstream/master' 2020-02-25 10:00:38 +00:00
sjmann b559cdd73f added traits exercises 2020-02-25 09:48:50 +00:00
fmoko ec51cdb229
Merge pull request from sjmann/master
docs(iterators): Updated iterators readme to account for iterators4 exercise
2020-02-22 15:34:51 +01:00
sjmann a3f70124dc fixed typo 2020-02-22 14:28:07 +00:00
sjmann bec8e3a644 reworded missing exercise explanation 2020-02-22 13:04:37 +00:00
bors c228a06e49 Auto merge of - QuintenJohnson:fix/installation-warning-messages, r=fmoko
fix(installation): make fatal errors more obvious

I initially ran the installation script without rust installed. The fact that the error message was labeled with WARNING made me unsure whether installation was successful or I needed to re-run after installing rust. There's an error code returned on fatal errors, but this change will make things clearer.
2020-02-21 20:56:11 +00:00
Quinten Johnson 17d0951e66 fix(installation): make fatal errors more obvious 2020-02-21 11:52:47 -06:00
Roberto Vidal 43dc31193a refactor: exercise evaluation
Exercise evaluation (compilation + execution) now uses Results
Success/failure messages are standardized
2020-02-20 20:27:05 +01:00
fmoko 83bbd9e82e
chore: Correct test command in tests1.rs comment ()
chore: Correct test command in tests1.rs comment
2020-01-29 15:39:10 +01:00
Jason Tsai 39fa7ae8b7 chore: Correct test command in tests1.rs comment 2020-01-29 13:48:43 +08:00
fmoko 3161a8fd9d
Fixed mangled sentence from book; edited for clarity ()
Fixed mangled sentence from book; edited for clarity
2020-01-25 13:27:53 +01:00
Paul Bissex ade52ffb73
Fixed mangled sentence from book; edited for clarity 2020-01-25 03:24:14 -05:00
fmoko 89c73647f1
Add variables5 to introduce shadowing ()
Add variables5 to introduce shadowing
2020-01-14 23:32:45 +01:00
Torben Jonas 0c73609e6f feat: Add variables5.rs exercise
closes 
2020-01-14 21:10:07 +01:00
fmoko 19a93428b3
fix: Update deps to version compatable with aarch64-pc-windows ()
fix: Update deps to version compatable with aarch64-pc-windows
2020-01-11 12:23:23 +01:00
Harrison Metzger 32a9cf7b8d fix: Update deps to version compatable with aarch64-pc-windows 2020-01-11 02:45:38 -06:00
fmoko c86b217e1d
Created consistent money unit ()
Created consistent money unit
2019-12-30 16:48:04 +01:00
gnodarse fd57f8f2c1 Created consistent money unit 2019-12-29 19:15:32 -05:00
bors 0d1f1a19b7 Auto merge of - codehearts:watch-completion-message, r=fmoko
feat: Show a completion message when watching

The completion message is shown only once all exercises succeed and are
not annotated with "I AM NOT DONE." The watch command will also exit

closes 

Let me know if there are any tests I could add or if the completion message should be tweaked!
2019-12-28 20:01:28 +00:00
Kate Hart d25ee55a32
feat: Show a completion message when watching
The completion message is shown only once all exercises succeed and are
not annotated with "I AM NOT DONE." The watch command will also exit

closes 
2019-12-26 20:27:49 -08:00
fmoko 3afa96bed4
Enable a test and improve per clippy's suggestion. ()
Enable a test and improve per clippy's suggestion.
2019-12-25 00:59:35 +01:00
dmitri-mamrukov dfdf8093eb
Enable a test and improve per clippy's suggestion. 2019-12-23 21:37:09 -05:00
fmoko 3906efcd52
fix(docs): Added a necessary step to Windows installation process 2019-12-22 13:21:24 +01:00
Socrates 2021a1ac7d
Update README.md
Added an essential step to Windows installation process (Setting ExecutionPolicy to RemoteSigned because it wouldn't install otherwise).
2019-12-22 14:16:04 +02:00
bors 426a7bb87f Auto merge of - AbdouSeck:conversions, r=fmoko
feat: Add type conversion and parsing exercises

This pull request adds exercises for converting values into specific types. The exercises uses string to struct type conversions, but most of the traits in the exercises can handle more than just string parsing and conversions.

The following traits are covered:
1. `From` and `Into`
2. `TryFrom` and `TryInto`
3. `AsRef`
4. `FromStr`

The `as` operator is also covered.
2019-12-16 16:41:03 +00:00
Abdou Seck fc26b5e151 I AM NOT DONE comment in conversions exercise files 2019-12-16 11:33:00 -05:00
Abdou Seck 0c85dc1193 feat: Add type conversion and parsing exercises 2019-12-16 09:12:13 -05:00
marisa fe10e06c37
fix(tests1): Change test command
Closes .
2019-12-16 13:05:25 +01:00
marisa 419f7797f2
fix(iterators2): Remove reference to missing iterators2.rs ()
fix(iterators2): Remove reference to missing iterators2.rs
2019-12-16 12:51:03 +01:00
Rahat Ahmed 54571a5fca
fix(iterators2): Remove reference to missing iterators2.rs 2019-12-07 23:25:13 -08:00
marisa 4b79691d5e 2.1.0 2019-11-27 10:46:09 +01:00
marisa 615ce32798
fix(enums): Add link to chapter on pattern syntax ()
Add link to chapter on pattern syntax
2019-11-25 12:16:51 +00:00
Jens 31c25ebb50
Add link to chapter on pattern syntax
After being stuck on exercise enums3.rs for about an hour or two, having read the entire chapter on enums 2-3 times, and still being unable to complete the exercise, i started broadening my reading. I finally found the answer in the rust docs via google.
2019-11-24 09:28:33 +01:00
bors f4acb888a6 Auto merge of - vyaslav:master, r=fmoko
feat(watch): show hint while watching

`rustlings hint ...` command is not convenient when doing exercises with `rustlings watch`.
This PR makes it possible for user to type `hint` while running `watch`  and get hint text for exercise which is currently failing.
e.g.
```rust
...
  --> exercises/variables/variables1.rs:13:36
   |
13 |     println!("x has the value {}", x);
   |                                    ^ not found in this scope

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0425`.

type 'hint' to get help:
hint
Hint: The declaration on line 12 is missing a keyword that is needed in Rust
to create a new variable binding.
```
2019-11-18 22:23:14 +00:00
vyaslav 8143d57b4e feat(watch): show hint while watching 2019-11-18 20:52:57 +01:00
bors a40ad092e9 Auto merge of - jrvidal:master, r=fmoko
fix: line numbers in several exercises and hints

The introduction of `I AM NOT DONE` shifted the lines of all exercises, which now need adjustment.
2019-11-14 08:23:50 +00:00
Roberto Vidal b565c4d3e7 fix: line numbers in several exercises and hints
The introduction of `I AM NOT DONE` shifted the lines of all
exercises, which now need adjustment.
2019-11-14 08:21:56 +01:00
bors e9a835c1c0 Auto merge of - ckeschnat:master, r=fmoko
fix(variables1): Correct wrong word in comment
2019-11-13 23:45:56 +00:00
bors cf38f03459 Auto merge of - ageorgou:functions4-update, r=fmoko
Update line numbers in hints and outdated comment

In functions4, the missing code is in line 14 in the latest version:
```rust
error: expected type, found `{`
  --> exercises/functions/functions4.rs:14:30
   |
14 | fn sale_price(price: i32) -> {
   |                              ^ expected type

error: aborting due to previous error
```
but the hint points to line 12. This is due to a recent change in 2cdd61294f.

Also includes similar updates for strings2 and primitive_types4.
2019-11-13 23:41:00 +00:00
Anastasis Georgoulas 4c5189df2b fix(primitive_types4): update outdated hint
Exercise was changed to test (and the order was switched) in .
2019-11-13 23:23:34 +00:00
Anastasis Georgoulas a09f684f05 fix(strings2): update line number in hint 2019-11-13 23:23:34 +00:00
ageorgou 8cc5af121c
Fix(functions4): Update line number in hint 2019-11-12 23:49:19 +00:00
Chris Keschnat c42c3b2101
fix(arc1): Fix some words in the comment 2019-11-12 18:37:23 +01:00
Chris Keschnat fda5a47069 fix(variables1): Correct wrong word in comment 2019-11-12 17:33:25 +01:00
marisa 57a837bde6
Merge pull request from jrvidal/master
fix(primitive_types4): update outdated comment
2019-11-12 13:00:28 +01:00
Roberto Vidal ded2c034ba fix(primitive_types4): update outdated comment 2019-11-12 12:52:28 +01:00
marisa eac07df96c 2.0.0 2019-11-12 12:24:30 +01:00
bors 8c1376df07 Auto merge of - rust-lang:fmoko-patch-1, r=fmoko
fix(default): Clarify the installation procedure
2019-11-12 11:13:06 +00:00
bors 45d68d9b39 Auto merge of - rust-lang:update-docs, r=fmoko
chore: Update docs for 2.0

Only merge this once we're ready to release 2.0.
2019-11-12 11:07:56 +00:00
marisa c371b853af
fix(default): Clarify the installation procedure 2019-11-12 11:53:58 +01:00
bors bc32a63c69 Auto merge of - jrvidal:no-prompt-on-run, r=fmoko
fix(run): makes `run` never prompt

`watch` and `verify` do prompt the user to actively move to the
next exercise. This change fixes `run` to never prompt. Previously
it was inconsistent between "test" and "compile" exercises.

BREAKING CHANGE: we again change the behavior of the `run` command
2019-11-12 10:50:19 +00:00
Roberto Vidal 4b26546589 fix(run): makes run never prompt
`watch` and `verify` do prompt the user to actively move to the
next exercise. This change fixes `run` to never prompt. Previously
it was inconsistent between "test" and "compile" exercises.

BREAKING CHANGE: we again change the behavior of the `run` command
2019-11-12 11:35:40 +01:00
bors bc56788fe6 Auto merge of - jrvidal:rustc-check, r=fmoko
feat(cli): check for rustc before doing anything

Addresses . From the backtraces shown there, it seems like we're not able to launch `rustc` (which is odd, given that they probably compiled and installed `rustlings` 🤷‍♀️)
2019-11-11 18:19:07 +00:00
marisa b4d41c1b7a chore: Update docs for 2.0 2019-11-11 18:02:56 +01:00
Roberto Vidal 36a033b87a feat(cli): check for rustc before doing anything
Addresses .
2019-11-11 18:00:54 +01:00
bors 9544ba1029 Auto merge of - rust-lang:refactor-hints, r=jrvidal
Refactor hints

Breaking change. This removes hints from the end of files, and puts them into `info.toml`. You can now access hints using:

```
rustlings hint <exerciseName>
```

ALSO this changes the exercise system to index by name for `run` and `hint`, so:

```
rustlings run exercises/if/if1.rs
```

becomes

```
rustlings run if1
```
2019-11-11 16:51:12 +00:00
marisa 1a7bb5a400 Address feedback 2019-11-11 17:47:45 +01:00
marisa 48c35bcfbc fix tests 2019-11-11 17:28:19 +01:00
marisa ec2d4bd3ee
Merge branch 'master' into refactor-hints 2019-11-11 17:21:06 +01:00
marisa ce9fa6ebbf feat(hint): Add test for hint 2019-11-11 17:19:50 +01:00
marisa 9a9007abae chore: Add .editorconfig file 2019-11-11 17:12:11 +01:00
bors 88ec6f6b16 Auto merge of - jrvidal:master, r=fmoko
Changes the execution mode for `watch`, asking for user input

We've [observed](https://hackmd.io/-cK6aPhnTwiCiI7u6k0xug?both) that learners can get confused when they do get everything right, but they _still_ get errors... which come from the next exercise, no the one they just edited.

This PR changes it so they have to confirm they want to move forward by removing the `I AM NOT DONE` comment.

![Screenshot at 2019-11-11 15:13:39](https://user-images.githubusercontent.com/1636604/68593566-0abd3900-0496-11ea-9e9d-6c43b91bf21d.png)

* [ ] The particular string is of course subject to bikeshed.

### Alternatives/doubts
* The coolest solution I could imagine would involve a proc-macro attribute `#![ready(false)]` that they could edit once they're done, but it's a bit complicated to set up.
* For now I've put `I AM NOT DONE` everywhere, I think it's what make more sense.
2019-11-11 15:59:35 +00:00
marisa 795b6e3480 fix(info): Fix trailing newlines for hints 2019-11-11 16:56:39 +01:00
marisa 9bdb0a12e4 feat: Refactor hint system
Hints are now accessible using the CLI subcommand `rustlings hint
<exercise name`.

BREAKING CHANGE: This fundamentally changes the way people interact with exercises.
2019-11-11 16:51:38 +01:00
Roberto Vidal 2cdd61294f feat: improve watch execution mode
The `watch` command now requires user action to move to the next
exercise.

BREAKING CHANGE: this changes the behavior of `watch`.
2019-11-11 16:23:35 +01:00
marisa 627cdc07d0 feat: Index exercises by name
BREAKING CHANGE: This changes the way you use `rustlings run` by now
requiring an abridged form of the previous filename, e.g:

`rustlings run exercises/if/if1.rs` becomes
`rustlings run if1`
2019-11-11 15:46:32 +01:00
marisa a47a62172a 1.5.1 2019-11-11 14:02:27 +01:00
marisa f72e5a8f05 fix(structs1): Remove misleading comment 2019-11-11 13:57:59 +01:00
marisa fbe91a67a4 fix(threads): Move Threads behind SLT
Closes .
2019-11-11 13:48:09 +01:00
marisa 6dcecb38a4 fix(strings): Move Strings before Structs
Closes .
2019-11-11 13:46:42 +01:00
marisa dcfb427b09 fix(errors3): Update hint
Closes .
2019-11-11 13:37:43 +01:00
marisa ad03d180c9 fix(if1): Remove return reference
This closes .
2019-11-11 13:34:21 +01:00
bors 3232a4d60d Auto merge of - WofWca:clear-screen, r=fmoko
improvement(watch): clear screen before each `verify()`

Closes 
It seems to me that  wasn't really fixing the issue.
2019-11-09 15:23:53 +00:00
WofWca 3aff590855 improvement(watch): clear screen before each verify()
Closes 
2019-11-09 22:24:24 +08:00
marisa c8babbad27 1.5.0 2019-11-09 10:52:20 +01:00
bors c6dad28ddc Auto merge of - nyxtom:feat-enums, r=fmoko
feat: Add enums exercises

Creates an exhaustive list of enum exercises. This goes through the basics of different ways to derive enums with mixed data type variants, as well as the use of the all important `match` operator.
2019-11-09 09:41:36 +00:00
bors fea81419cd Auto merge of - workingjubilee:watch-clears-terminal, r=fmoko
watch: clears terminal before entering loop

Fixes 

If someone is sliding in and out of "watch" mode, it can make it hard
to tell which error messages are still relevant. This patch resolves
that by clearing the terminal entirely before entering watch's loop.

Note that the escape character is chosen for compatibility reasons, because different shells/terminals can change which commands they accept or have installed, betting on what other commands are in use to collect data seems risky, and just expecting them to implement ANSI escape code sequences is more reliable. This seems especially true since Windows is seeking more UNIX compatibility in its terminals going forward, even though it doesn't implement the POSIX standard per se.
2019-11-09 09:31:50 +00:00
Jubilee Young 83be517e77 watch: clears terminal before entering loop
If someone is sliding in and out of "watch" mode, it can make it hard
to tell which error messages are still relevant. This patch resolves
that by clearing the terminal entirely before entering watch's loop.
2019-11-09 00:57:36 -08:00
marisa 79a569422c
fix: Rewrite test1 logic 2019-10-29 20:53:41 +01:00
bors 1e0b12e37e Auto merge of - ssweeny:fix/test1-wording, r=fmoko
chore: Clarify comment in exercises/test1.rs

closes 

The author of issue  suggests that the wording of the comment is at
least ambiguous about the desired results. I believe this change more
clearly describes the expectation of the exercise.
2019-10-29 13:37:30 +00:00
Thomas Holloway dc15032112 feat: Add enums exercises 2019-10-28 22:49:49 -05:00
Scott Sweeny 2821227acf chore: Clarify comment in exercises/test1.rs
closes 

The author of issue  suggests that the wording of the comment is at
least ambiguous about the desired results. I believe this change more
clearly describes the expectation of the exercise.
2019-10-28 23:08:46 -04:00
bors 2191ef7eee Auto merge of - vyaslav:master, r=fmoko
Added exercise for struct update syntax

Added one exercise for struct update syntax `struct2.rs`
2019-10-28 22:56:54 +00:00
marisa 4c2cf6da75
fix(option1): Fix arguments passed to assert! macro ()
fix(option1): Fix arguments passed to assert! macro
2019-10-26 00:27:40 +02:00
marisa 0f3d6d871e
chore: Bump version in Cargo.lock ()
chore: Bump version in Cargo.lock
2019-10-26 00:27:17 +02:00
Niklas Anderson bd007d4617 chore: Bump version in Cargo.lock 2019-10-25 14:57:30 -07:00
Niklas Anderson ead4f7af9e fix(option1): Fix arguments passed to assert! macro 2019-10-25 14:27:24 -07:00
marisa 4808b5b3ba
Update README to show latest version, for those who copy/paste ()
Update README to show latest version, for those who copy/paste
2019-10-25 01:54:10 +02:00
Mark Provan f3da6796b9
Update README to show latest version, for those who copy/paste 2019-10-24 13:56:14 +01:00
marisa cece12e87e docs: Add automatic Windows support to Readme 2019-10-23 13:01:07 +02:00
marisa 68d1727cac chore(ci): Remove GitHub actions for now 2019-10-23 12:56:07 +02:00
bors 8a2e13b20a Auto merge of - gdoenlen:master, r=fmoko
Add windows install script

Adds a powershell install script for windows users that are at least
running powershell 5. It is almost a direct port of install.sh.
This would be used to automatically download the script much like
curl | bash, but with:

`Invoke-WebRequest https://urltoscript.com | Select-Object
-ExpandProperty Content | Out-File $env:TMP/install_rustlings.ps1;
Unblock-File $env:TMP/install_rustlings.ps1; Invoke-Expression
$env:TMP/install_rustlings.ps1`
2019-10-23 10:49:36 +00:00
George Doenlen ee311b8e5c remove execution policy check 2019-10-22 22:26:33 -04:00
George Doenlen f0de6c4e92 Add basic windows install script.
Adds a powershell install script for windows users that are at least
running powershell 5. It is almost a direct port of install.sh.
This would be used to automatically download the script much like
curl | bash, but with:

`Invoke-WebRequest https://urltoscript.com | Select-Object
-ExpandProperty Content | Out-File $env:TMP/install_rustlings.ps1;
Unblock-File $env:TMP/install_rustlings.ps1; Invoke-Expression
$env:TMP/install_rustlings.ps1`
2019-10-22 21:56:50 -04:00
Viacheslav Avramenko 1c4c8764ed feat: Added exercise for struct update syntax 2019-10-21 14:50:59 +02:00
bors e6161a6f58 Auto merge of - timthelion:timthelion-readme-run, r=fmoko
Tense in README

Don't see why run should be past tense.  At least in my native General American dialect it shouldn't be.
2019-09-25 14:09:52 +00:00
Timothy Hobbs 8c0fe59c90
Tense in README
Don't see why run should be past tense.  At least in my native General American dialect it shouldn't be.
2019-09-07 16:17:45 +00:00
komaeda 17690b3add
chore(ci): Add GitHub Actions CI file 2019-08-21 13:23:38 +02:00
bors f9987c8bed Auto merge of - sosnowski:fix/add-dyn-trait, r=komaeda
fix(errorsn.rs) Update the deprecated syntax by adding dyn to trait o…

fix(errorsn.rs) Update the deprecated syntax by adding dyn to trait objects.

closes 

Related issue: https://github.com/rust-lang/rustlings/issues/211
2019-08-21 11:01:11 +00:00
Damian S 8109cbad97 fix(errorsn.rs) Update the deprecated syntax by adding dyn to trait objectscloses 2019-08-21 11:44:42 +01:00
bors c5bb32253b Auto merge of - Dylnuge:slice-assert, r=komaeda
fix(primitive_types4): Fail on a slice covering the wrong area

I noticed this issue and it seems like a similar one was raised/fixed in  this way. This is my first contribution to this repo (or any Rust project) so let me know if I messed up or need to fix anything!

---
This commit converts primitive_types4 to a test and asserts that the
slice given is equal to the expected slice.

The intent of the primitive_types4 exercise appears to be to ensure the
user understands inclusive and exclusive bounds as well as slice syntax.
`rustlings` commands using `compile` do not verify that a specific
println is reached and, in the case of `watch` and `verify` (but not
`run`), they do not output the `println`s at all.

This fix is semantically similar to . It does not take a stance on
the correct way to handle this for all exercises; see . There are
likely other exercises whose intent are masked by this issue.
2019-08-18 08:24:44 +00:00
Dylan Nugent 5b1e673cec fix(primitive_types4): Fail on a slice covering the wrong area
This commit converts primitive_types4 to a test and asserts that the
slice given is equal to the expected slice.

The intent of the primitive_types4 exercise appears to be to ensure the
user understands inclusive and exclusive bounds as well as slice syntax.
`rustlings` commands using `compile` do not verify that a specific
println is reached and, in the case of `watch` and `verify` (but not
`run`), they do not output the `println`s at all.

This fix is semantically similar to . It does not take a stance on
the correct way to handle this for all exercises; see . There are
likely other exercises whose intent are masked by this issue.
2019-08-17 17:16:19 -07:00
bors 2cd06826c0 Auto merge of - ajaxm:ajaxm/rustup-update, r=komaeda
Suggest rustup update in readme

I'm pretty new to Rust. I tried installing rustlings for the first time and got this error:
```
$> cargo install --force --path .
error: `/Users/ajax/projects/rust/rustlings` is not a crate root; specify a crate to install from crates.io, or use --path or --git to specify an alternate source

Caused by:
  failed to parse manifest at `/Users/ajax/projects/rust/rustlings/Cargo.toml`

Caused by:
  editions are unstable

Caused by:
  feature `edition` is required

this Cargo does not support nightly features, but if you
switch to nightly channel you can add
`cargo-features = ["edition"]` to enable this feature
```

I'm not sure if the answer was to run `rustup update` but I noticed that I was running Rust 1.29.0, so updated to 1.36.0 and got it working. If there's a way to specify a minimum required version, pls let me know.

Lastly, the whitespace changes were automatic from my editor. What's the convention here for making such updates? Thanks!
2019-08-13 10:04:36 +00:00
marisa 4f0c5a8d49
1.4.1 2019-08-13 11:59:17 +02:00
bors 3011251da7 Auto merge of - EnricoMiccoli:patch-1, r=komaeda
chore: Correct typo in hint text
2019-08-12 15:24:17 +00:00
Enrico Miccoli 76b4cb5c00
chore: Correct typo 2019-08-12 11:45:40 +02:00
bors f83af3c25d Auto merge of - nkanderson:fix_iterators2, r=komaeda
Fix iterators2

A couple of small changes to the `iterators2` exercise. @Jesse-Cameron, it looks like you contributed this exercise, so I wanted to check and see if these changes are in line with your intentions. Happy to adjust if they're not :)
2019-08-11 15:44:40 +00:00
Niklas Anderson e3931718fb chore(iterators2): Add exercise instructions 2019-08-09 07:38:21 -07:00
Niklas Anderson 4cde86643e fix(iterators2): Remove syntax resulting in misleading error message
closes 
2019-08-09 07:37:27 -07:00
Ajax Manohar 9ee3207280 docs: Suggest rustup update in readme 2019-08-03 10:49:37 -07:00
bors e696a07190 Auto merge of - zdzc:patch-1, r=komaeda
docs: Fix wrong title

fix 
2019-07-27 19:07:22 +00:00
Andre Pratama e0db987441
docs: Fix wrong title
fix 
2019-07-27 22:14:48 +07:00
bors 1890b0019d Auto merge of - nkanderson:160_options1-add-test, r=komaeda
fix(option1): Add test for prematurely passing exercise

Fixes the bug referenced in , but does not address the larger feature work referenced by the issue.
2019-07-27 10:32:47 +00:00
Niklas Anderson a750e4a1a3 fix(option1): Add test for prematurely passing exercise
Fixes the bug referenced in , but does not address the larger feature work referenced by the issue.
2019-07-26 16:58:12 -07:00
bors 1c789dda08 Auto merge of - petemcfarlane:patch-2, r=komaeda
fix(test1): Swap assertion parameter order

`Expected` should come before `actual`, other wise it leads to confusing compiler messages, e.g.
```
note: expected type `()`
         found type `{integer}`
```
There may be other tests that need updating, but this is as far as I am through the Rustlings course right now :)
2019-07-13 16:27:14 +00:00
Pete McFarlane 4086d463a9
fix(test1): Swap assertion parameter order
`Expected` should come before `actual`, other wise it leads to confusing compiler messages, e.g.
```
note: expected type `()`
         found type `{integer}`
```
2019-07-13 13:31:57 +01:00
marisa b8368de6d5
1.4.0 2019-07-13 12:50:22 +02:00
bors 7dc90094d2 Auto merge of - MrFroop:master, r=komaeda
Fix(watch): Check if changed exercise file exists before calling verify.

Prevent a panic if the file triggering the watch event is gone.
2019-07-12 08:16:35 +00:00
Fredrik Jambrén ba85ca32c4 Check if changed exercise file exists before calling verify. 2019-07-11 23:54:18 +02:00
etisdew 70946b85e5 fix(readme): http to https
changing readme image (line 1) to https fixes markdown preview and improves fidelity
2019-07-08 16:58:14 +02:00
bors 1570c328c6 Auto merge of - Jesse-Cameron:iterator-exercise2, r=komaeda
feat(iterators2): adds iterators2 exercise including config

Hi there!

I really enjoyed doing the rustlings exercises so I thought that I would try to add an exercise!

This one just covers a couple of basic iterator operations. Getting people used to the `map` and `collect` functions.

However, it does feel kinda similar to the next exercise. So I may also revisit some of the tests in iterators3 if we think that is necessary.
2019-07-04 11:35:40 +00:00
Jesse 9288fccf07 feat(iterators2): adds iterators2 exercise including config 2019-07-03 21:06:24 +10:00
bors 5e1d7c3076 Auto merge of - Jesse-Cameron:master, r=komaeda
fix(test1): renamed function name to snake case

addressing a minor function naming convention, see: [RFC ](https://doc.rust-lang.org/1.0.0/style/style/naming/README.html)

closes 
2019-06-28 15:27:40 +00:00
Jesse 89d5186c0d fix(test1): renamed function name to snake case
closes 
2019-06-29 01:00:10 +10:00
bors aaad60d07e Auto merge of - miller-time:fix-book-links, r=komaeda
chore: Fix a couple broken book links

While I was fixing these, I figured maybe it's good to just use a consistent URL for book links: https://doc.rust-lang.org/book/

Is there a plan for what to do with this old 1.4.0 example that doesn't exist in the current version of the book? Perhaps at least include a disclaimer when recommending that folks check it out?

34e31232df/exercises/threads/README.md (L1)
2019-06-23 10:31:50 +00:00
bors 5f16469807 Auto merge of - miller-time:rustfmt-exercises, r=komaeda
chore: Clean up some formatting in exercises

I noticed some formatting that isn't consistent with the `rustfmt` style and tried my best to run it on the files in the exercises directory (which does fail for files that can't compile!), which just caught some minor whitespace things here and there.

Note: also can't just apply `rustfmt` blindly because of the blank lines that lead to the hint comments
2019-06-23 10:25:48 +00:00
bors 752bc27e2b Auto merge of - briankung:fix_irrefutable_let_pattern_structs1, r=komaeda
Fixes the irrefutable let pattern warning in `structs1.rs`

PR https://github.com/rust-lang/rustlings/pull/163 accidentally introduced an error using some versions of the Rust compiler where the compiler would (rightly!) complain about an irrefutable let pattern. I have no idea why this did not occur in all versions of the compiler, but here is a way around it.
2019-06-20 15:02:20 +00:00
Brian Kung cc6a14104d Fixes the irrefutable let pattern warning 2019-06-20 09:46:49 -05:00
Russell Cousineau eb13c2b6af chore: Clean up some formatting in exercises 2019-06-11 07:14:43 -07:00
Russell Cousineau 63c133e4a3 chore: Fix a couple broken book links 2019-06-11 07:13:05 -07:00
bors b8d59d699b Auto merge of - miller-time:fix-install-script, r=komaeda
fix(installation): Fix rustlings installation check

fixes 

I did some quick testing with the `-x` check:

```sh
if [ -x "$(notrustlings)" ]
then
    echo "notrustlings does not exist"
else
    echo "notrustlings appears to exist!"
    notrustlings
fi
```

which produced:

```
./test.sh: line 12: notrustlings: command not found
notrustlings appears to exist!
./test.sh: line 17: notrustlings: command not found
```

(consistent with comments in issue)

Using `if ! [ -x "$(command -v <command>)" ]` appears to be the standard way to perform this type of check.
2019-06-11 13:53:07 +00:00
bors 5586613eec Auto merge of - miller-time:rename-iterator-exercise, r=komaeda
fix(iterators): Rename iterator3.rs

fixes 
2019-06-11 12:53:58 +00:00
bors ad8e6dc63b Auto merge of - danwilhelm:dan-minor-text, r=komaeda
chore: Minor text updates

- Make the default rustlings executable text consistent with the README and install script by adding `--force`.

- Remove a missed highlighting character from Issue .
2019-06-11 09:38:18 +00:00
Dan Wilhelm f72e0ca979 chore: Remove missed highlighting char from Issue 2019-06-10 20:24:18 -07:00
Dan Wilhelm 03cfe67500 chore: Make install instructions consistent 2019-06-10 20:20:22 -07:00
Russell Cousineau 7a252c4755 fix(installation): Fix rustlings installation check 2019-06-09 07:40:54 -07:00
liv 2089901739 docs: Move content from Readme to Contributing 2019-06-09 14:46:38 +02:00
liv 635e506c16 docs: Recommend rustlings watch as default 2019-06-09 14:44:16 +02:00
liv 75d8c7e3cc docs: Add CONTRIBUTING.md 2019-06-09 14:39:00 +02:00
Rohan Prinja 080d6cdd11 chore: Fix link to Arc<T> in the book 2019-06-09 13:45:53 +02:00
Russell Cousineau 433d2115bc fix(iterators): Rename iterator3.rs 2019-06-07 14:42:44 -07:00
liv 34e31232df feat(changelog): Use clog for changelogs 2019-06-05 13:14:51 +02:00
liv 7fca1d28af 1.3.0 2019-06-05 12:37:02 +02:00
bors 9c3d765403 Auto merge of - rust-lang:fix/remove-highlighting, r=komaeda
Remove highlighting and syntect

Closes  and 
2019-06-05 10:23:37 +00:00
liv bb652ceb91 Commit Cargo.lock file 2019-06-05 12:22:41 +02:00
liv 62696f5819 Remove highlighting and syntect 2019-06-05 12:18:50 +02:00
bors 41170ce341 Auto merge of - HanKruiger:master, r=komaeda
Fix broken link
2019-05-26 14:07:16 +00:00
bors e2092a4ddd Auto merge of - gushroom:fix-outdated-links, r=komaeda
fixed outdated links

The links had the 2018 book in them and they were outdated.
2019-05-26 13:58:24 +00:00
gushroom fd1441d122 fixed outdated links 2019-05-26 14:57:56 +02:00
HanKruiger e1422c6443 Fix broken link 2019-05-26 14:45:04 +02:00
bors 1f07fd4150 Auto merge of - briankung:add_structs, r=komaeda
Adds a simple exercise for structures

Thanks for rustlings! Here's a small contribution in return.
2019-05-25 13:40:15 +00:00
Brian Kung 9b92aa08ae Adds a simple exercise for structures 2019-05-25 06:39:58 -05:00
bors 8bf8cbbd61 Auto merge of - c-rustacean:rustfmt-and-ws-fixes, r=komaeda
errorsn.rs: Separate also the hints from each other to avoid accidental viewing
2019-05-23 11:01:15 +00:00
Eddy Petrisor f507844102 errorsn.rs: Separate also the hints from each other to avoid accidental viewing
Signed-off-by: Eddy Petrisor <eddy.petrisor@gmail.com>
2019-05-23 12:21:42 +03:00
bors fffbb60ed9 Auto merge of - c-rustacean:rustfmt-and-ws-fixes, r=komaeda
Rustfmt and ws fixes
2019-05-22 12:29:20 +00:00
Eddy Petrisor 9aec4abc4d rustfmt the exercises
Signed-off-by: Eddy Petrisor <eddy.petrisor@gmail.com>
2019-05-22 14:50:40 +03:00
Eddy Petrisor a53b3f199f iterator3.rs: whitespace fixes
Signed-off-by: Eddy Petrisor <eddy.petrisor@gmail.com>
2019-05-22 14:50:40 +03:00
Eddy Petrisor d6d696b66a errorsn.rs: Separate hints from code, so hints are not accidentally seen
Signed-off-by: Eddy Petrisor <eddy.petrisor@gmail.com>
2019-05-22 14:50:39 +03:00
Eddy Petrisor ca6bf966dd Cargo fmt the rustlings application code
Signed-off-by: Eddy Petrisor <eddy.petrisor@gmail.com>
2019-05-22 14:50:23 +03:00
liv 5a9f8860ca
Add not passing integration test ()
Add not passing integration test
2019-05-22 10:53:46 +02:00
liv 5423bc66a9
Update errors1.rs - Add Result type signature as it is difficult for new comers to understand Generics and Error all at once. ()
Update errors1.rs - Add Result type signature as it is difficult for new comers to understand Generics and Error all at once.
2019-05-22 10:53:18 +02:00
Julien Bisconti 187d2ad226
Update errors1.rs
Add Result type signature as it is difficult for new comers to understand Generics and Error all at once
2019-05-12 14:54:37 +02:00
Denys Smirnov 7cf0d5d15e Add not passing integration test 2019-05-09 20:17:38 +03:00
liv 1f2ee8cb62 1.2.2 2019-05-07 12:32:50 +02:00
liv 35c3d0b3fc Revert --nocapture flag
This closes  and 
2019-05-07 12:31:02 +02:00
liv 0279294972 1.2.1 2019-04-22 19:12:30 +08:00
liv 7eddee6f7a add a slightly more helpful error message 2019-04-22 18:43:39 +08:00
liv f2c48cfac5 fix the --nocapture functionality 2019-04-22 18:42:32 +08:00
liv 6ae0a00211 1.2.0 2019-04-22 13:09:28 +08:00
liv bfcf38c8bc
damn it 2019-04-22 07:05:46 +02:00
liv 9e328da641
use -- --nocapture when testing 2019-04-22 05:49:23 +02:00
bors e336d04c79 Auto merge of - yvan-sraka:patch-0, r=komaeda
Add errors to exercises that compile without user changes

Hi !

I played a bit with rustlings, and I felt that some exercises were incorrect because they passed the tests without me needing to edit the files!

This gave me the feeling that the exercise was skiped! Especially when I use `rustlings watch`, it is easy to miss an exercise because the compilation error that is displayed is the one of the next exercise ...

It is easy to identify "broken" exercises with:

```bash
% find exercises -name "*.rs" | xargs -n 1 rustlings run
...
 Successfully ran exercises/move_semantics/move_semantics4.rs
 Successfully tested exercises/test2.rs
```

My suggestion is to make sure that these files trigger a compilation error by adding a simple syntax error (e.g. with `???` in the code that must change) so that our Rustacean can then play with it!
2019-04-22 01:50:48 +00:00
Yvan Sraka a71bc62c29
Add errors to exercises that compile without user changes 2019-04-22 00:09:30 +02:00
liv 4b0b7093e5 1.1.1 2019-04-14 18:29:32 +02:00
bors 8387de64d3 Auto merge of - cjpearce:fix-exercise-path-matching, r=komaeda
Canonicalize paths to fix path matching

This PR should fix . The main solution to the issue was using `canonicalize()` on the paths we create for the exercises from `info.toml` and any user-specified paths, so that path `ends_with` matching will work correctly.

As adding calls to the canonicalize function everywhere requires unwrapping, I also decided to extract a struct representing an exercise and use serde to deserialize the paths from the `info.toml` file up front. I also tried to move the path handling out into the `exercise.rs` file and down into `main.rs` so that it doesn't create as much clutter. There was already a lot of unwrapping and path handling in the other files and I felt like it was getting a bit too repetitive.

If the approach is going too far (too many changes etc.) I'm happy to try to produce a smaller PR that fixes the bug without any refactoring.
2019-04-13 16:32:02 +00:00
Chris Pearce 77de6e5d6a Clean up test includes for File and Path 2019-04-12 23:14:15 +01:00
Chris Pearce 8c867a001a Remove unwrap on canonicalize result 2019-04-12 22:24:13 +01:00
Chris Pearce d01a71f7de Extract exercise struct to encapsulate path logic 2019-04-12 08:58:25 +01:00
bors 04d1d4c00e Auto merge of - diodfr:patch-1, r=komaeda
Fix links by deleting book version
2019-04-08 20:05:34 +00:00
Diod FR d7e58ee1af
Fix links by deleting book version 2019-04-08 22:02:04 +02:00
bors ffb165ce26 Auto merge of - cjpearce:fix/test-race-condition, r=komaeda
Fix intermittent test failure caused by race condition

First public pull request 😬

There's an intermittent integration test failure when you use multiple test threads (at least for me on a mac). I narrowed it down to two tests each spawning a process using `Command` which then try to compile the same file at the same time. If the timing doesn't work out, they both try to compile, and then one process runs `clean` before the other can run the executable - causing a panic.

![Screenshot 2019-04-07 at 19 54 55](https://user-images.githubusercontent.com/3453268/55688324-20520980-596f-11e9-8474-5215d61a4387.png)

You can prevent it from happening by running with a single thread (`cargo test -- --test-threads=1`), because the `Command` blocks. That's not a particularly good solution though because it's not something you can configure in `Cargo.toml`.

I considered making the affected tests just run serially, but it occurred to me that this could also happen if someone accidentally runs rustlings in watch mode in two terminals without realising it. I wound't consider this that unlikely given it's a tool for learning.

I fixed it by ensuring that the executables made from separate processes don't conflict by appending a process id to the output executable name. I also extracted the commands into a single file next to `clean` so that we don't have to repeat the generated file name everywhere and risk missing something.
2019-04-07 22:37:34 +00:00
Chris Pearce 65cb09eb2e Update ci test command to allow multithreaded tests 2019-04-07 21:23:02 +01:00
bors 78552ebd7a Auto merge of - cjpearce:fix/run-panics-on-compile-fail, r=komaeda
Stop run from panicking when compile fails

Currently if you use the `rustlings run` command and your program fails to compile, rustlings will panic while trying to exit.

First I've added a couple of integration tests to cover this case, which also meant moving a few tests so that the new fixtures didn't cause `verify_all_success` to fail.

Then I noticed that the existing integration tests that test for failure pass even when rustlings panics, preventing the new tests from failing. I've updated the integration tests to distinguish between when rustlings has failed in the way that we want (exit code 1) rather than a panic (exit code 101).

Finally I fixed the actual panic, which was just caused by unwrapping when rustlings should probably be exiting cleanly.
2019-04-07 20:11:22 +00:00
Chris Pearce 0c7bd12372 Fix test failing due to panic 2019-04-07 20:13:04 +01:00
Chris Pearce 3d11d7685b Modify integration tests to fail on panic 2019-04-07 20:13:04 +01:00
Chris Pearce 592ae6b4d2 Add process id to temp file name 2019-04-07 17:28:51 +01:00
Chris Pearce 4fa79ee02f Extract command builders into util 2019-04-07 17:26:01 +01:00
bors fbd0ccbd5b Auto merge of - rust-lang:fix/windows-paths, r=komaeda
fix watch command path execution

@hades32 @guttume could you test whether this works on windows by checking out the branch locally and running `cargo run watch`?
2019-04-03 09:37:37 +00:00
komaeda 8c008a0e7d
Merge pull request from mgeier/patch-1
Fix order of true/false in tests for executables
2019-03-28 12:11:35 +01:00
Matthias Geier 11fe19d08a
Fix order of true/false in tests for executables
1b3469f236 has fixed the tests themselves, but now the original error shows itself.
2019-03-28 11:53:29 +01:00
liv 1b3469f236 make installation command checks more thorough 2019-03-28 10:51:54 +01:00
liv 022921168d fix watch command path execution 2019-03-27 10:58:56 +01:00
komaeda c6765eb3eb
Merge pull request from zacanger/bug/permissions
Fix permissions on exercise files
2019-03-24 15:44:34 +01:00
zacanger c5a374fbf2
Fix permissions on source files 2019-03-23 14:19:42 -06:00
lyn f3ee70489f 1.1.0 2019-03-20 21:27:27 +01:00
lyn 6a27ba735c cargo fmt 2019-03-20 21:25:45 +01:00
komaeda 91dce31265
Merge pull request from ColinPitrat/master
Verify that rust version is recent enough to install rustlings.
2019-03-20 21:22:04 +01:00
lyn 040ca18a64 add travis config 2019-03-20 21:08:08 +01:00
lyn f43cb124f6 add tests 2019-03-20 21:05:45 +01:00
komaeda 11875aed6e
adjust author name 2019-03-20 14:51:28 +01:00
Colin Pitrat f07703eb7a
Fix comment position 2019-03-20 11:21:15 +00:00
Colin Pitrat fd4eda8bda Verify that rust version is recent enough to install rustlings.
I would have liked to write some tests for the vercomp function I
introduce, but there doesn't seem to be any CI setup yet?
2019-03-20 11:18:39 +00:00
komaeda bf8d927ab2
Merge pull request from kisom/master
Be nicer when rustlings isn't run from the right directory.
2019-03-17 22:28:03 +01:00
Kyle Isom 9fc4a83987 Be nicer when rustlings isn't run from the right directory.
Before, rustlings would panic if it wasn't in the right directory. It
took me a minute to figure out why, and this wasn't my first intro to
Rust. It would probably help new users if they saw a helpful message
instead of a stack trace.
2019-03-17 11:43:47 -07:00
komaeda 63280ed9e4
Merge pull request from LesnyRumcajs/patch-1
Add standard library types to exercises suite
2019-03-17 13:27:48 +01:00
komaeda 25f9d61410
Merge pull request from kisom/update-link
errors2.rs: update link to Rust book.
2019-03-17 13:19:57 +01:00
Kyle Isom c1f4257a91 errors2.rs: update link to Rust book. 2019-03-16 19:22:06 -07:00
komaeda 8f9d7ce3d8
Merge pull request from abagshaw/master
Start verification at most recently modified file
2019-03-16 12:54:09 +01:00
Andrew Bagshaw 3b5dfac44e Remove unnessecary whitespace 2019-03-15 16:01:45 -07:00
Andrew Bagshaw a6a8b61b12
Change to \n 2019-03-15 12:47:06 -07:00
Andrew Bagshaw 6cd42bb821 Add clear break between verify executions 2019-03-13 14:08:28 -07:00
Andrew Bagshaw 4d7ce6e571 deduplicate 2019-03-13 13:53:24 -07:00
Andrew Bagshaw 3f114cc069 Start verification at most recently modified file 2019-03-13 13:50:54 -07:00
LesnyRumcajs 58ccd72aff
Add standard library types to exercises suite 2019-03-13 15:29:02 +01:00
lyn abf175111d clippy-ify 2019-03-11 15:09:20 +01:00
lyn 9144c816bf remove obsolete paragraph on --test flag 2019-03-06 22:01:45 +01:00
lyn 999601d828 1.0.1 2019-03-06 21:58:10 +01:00
lyn 10d4d61d19 rework contribution guide for the new toml file 2019-03-06 21:55:48 +01:00
lyn 70e59cca3c standardize exercise running via an external toml file 2019-03-06 21:47:33 +01:00
komaeda 7d6e2812fb
Merge pull request from shaunbennett/master
Watch for file creation events in watch mode
2019-03-06 20:28:29 +01:00
lyn 05e8f02d0a edit readme to use the install script 2019-03-06 20:25:27 +01:00
lyn 9a14d72f08 add a basic install script 2019-03-06 20:16:31 +01:00
Shaun Bennett 04d0f78a2c Fix file watching for vim swap files 2019-03-06 18:38:55 +00:00
136 changed files with 6857 additions and 2055 deletions

922
.all-contributorsrc Normal file
View file

@ -0,0 +1,922 @@
{
"files": [
"README.md"
],
"imageSize": 100,
"commit": false,
"contributors": [
{
"login": "carols10cents",
"name": "Carol (Nichols || Goulding)",
"avatar_url": "https://avatars2.githubusercontent.com/u/193874?v=4",
"profile": "http://carol-nichols.com",
"contributions": [
"code",
"content"
]
},
{
"login": "QuietMisdreavus",
"name": "QuietMisdreavus",
"avatar_url": "https://avatars2.githubusercontent.com/u/5217170?v=4",
"profile": "https://twitter.com/QuietMisdreavus",
"contributions": [
"code",
"content"
]
},
{
"login": "robertlugg",
"name": "Robert M Lugg",
"avatar_url": "https://avatars0.githubusercontent.com/u/6054540?v=4",
"profile": "https://github.com/robertlugg",
"contributions": [
"content"
]
},
{
"login": "hynek",
"name": "Hynek Schlawack",
"avatar_url": "https://avatars3.githubusercontent.com/u/41240?v=4",
"profile": "https://hynek.me/about/",
"contributions": [
"code"
]
},
{
"login": "spacekookie",
"name": "Katharina Fey",
"avatar_url": "https://avatars0.githubusercontent.com/u/7669898?v=4",
"profile": "https://spacekookie.de",
"contributions": [
"code"
]
},
{
"login": "lukabavdaz",
"name": "lukabavdaz",
"avatar_url": "https://avatars0.githubusercontent.com/u/9624558?v=4",
"profile": "https://github.com/lukabavdaz",
"contributions": [
"code",
"content"
]
},
{
"login": "evestera",
"name": "Erik Vesteraas",
"avatar_url": "https://avatars2.githubusercontent.com/u/4187449?v=4",
"profile": "http://vestera.as",
"contributions": [
"code"
]
},
{
"login": "Delet0r",
"name": "delet0r",
"avatar_url": "https://avatars1.githubusercontent.com/u/23195618?v=4",
"profile": "https://github.com/Delet0r",
"contributions": [
"code"
]
},
{
"login": "shaunbennett",
"name": "Shaun Bennett",
"avatar_url": "https://avatars1.githubusercontent.com/u/10522375?v=4",
"profile": "http://phinary.ca",
"contributions": [
"code"
]
},
{
"login": "abagshaw",
"name": "Andrew Bagshaw",
"avatar_url": "https://avatars2.githubusercontent.com/u/8594541?v=4",
"profile": "https://github.com/abagshaw",
"contributions": [
"code"
]
},
{
"login": "kisom",
"name": "Kyle Isom",
"avatar_url": "https://avatars2.githubusercontent.com/u/175578?v=4",
"profile": "https://ai6ua.net/",
"contributions": [
"code"
]
},
{
"login": "ColinPitrat",
"name": "Colin Pitrat",
"avatar_url": "https://avatars3.githubusercontent.com/u/1541863?v=4",
"profile": "https://github.com/ColinPitrat",
"contributions": [
"code"
]
},
{
"login": "zacanger",
"name": "Zac Anger",
"avatar_url": "https://avatars3.githubusercontent.com/u/12520493?v=4",
"profile": "https://zacanger.com",
"contributions": [
"code"
]
},
{
"login": "mgeier",
"name": "Matthias Geier",
"avatar_url": "https://avatars1.githubusercontent.com/u/705404?v=4",
"profile": "https://github.com/mgeier",
"contributions": [
"code"
]
},
{
"login": "cjpearce",
"name": "Chris Pearce",
"avatar_url": "https://avatars1.githubusercontent.com/u/3453268?v=4",
"profile": "https://github.com/cjpearce",
"contributions": [
"code"
]
},
{
"login": "yvan-sraka",
"name": "Yvan Sraka",
"avatar_url": "https://avatars2.githubusercontent.com/u/705213?v=4",
"profile": "https://yvan-sraka.github.io",
"contributions": [
"code"
]
},
{
"login": "dendi239",
"name": "Denys Smirnov",
"avatar_url": "https://avatars3.githubusercontent.com/u/16478650?v=4",
"profile": "https://github.com/dendi239",
"contributions": [
"code"
]
},
{
"login": "eddyp",
"name": "eddyp",
"avatar_url": "https://avatars2.githubusercontent.com/u/123772?v=4",
"profile": "https://github.com/eddyp",
"contributions": [
"code"
]
},
{
"login": "briankung",
"name": "Brian Kung",
"avatar_url": "https://avatars1.githubusercontent.com/u/2836167?v=4",
"profile": "http://about.me/BrianKung",
"contributions": [
"code",
"content"
]
},
{
"login": "miller-time",
"name": "Russell",
"avatar_url": "https://avatars3.githubusercontent.com/u/281039?v=4",
"profile": "https://rcousineau.gitlab.io",
"contributions": [
"code"
]
},
{
"login": "danwilhelm",
"name": "Dan Wilhelm",
"avatar_url": "https://avatars3.githubusercontent.com/u/6137185?v=4",
"profile": "http://danwilhelm.com",
"contributions": [
"doc"
]
},
{
"login": "Jesse-Cameron",
"name": "Jesse",
"avatar_url": "https://avatars3.githubusercontent.com/u/3723654?v=4",
"profile": "https://github.com/Jesse-Cameron",
"contributions": [
"code",
"content"
]
},
{
"login": "MrFroop",
"name": "Fredrik Jambrén",
"avatar_url": "https://avatars3.githubusercontent.com/u/196700?v=4",
"profile": "https://github.com/MrFroop",
"contributions": [
"code"
]
},
{
"login": "petemcfarlane",
"name": "Pete McFarlane",
"avatar_url": "https://avatars3.githubusercontent.com/u/3472717?v=4",
"profile": "https://github.com/petemcfarlane",
"contributions": [
"content"
]
},
{
"login": "nkanderson",
"name": "nkanderson",
"avatar_url": "https://avatars0.githubusercontent.com/u/4128825?v=4",
"profile": "https://github.com/nkanderson",
"contributions": [
"code",
"content"
]
},
{
"login": "ajaxm",
"name": "Ajax M",
"avatar_url": "https://avatars0.githubusercontent.com/u/13360138?v=4",
"profile": "https://github.com/ajaxm",
"contributions": [
"doc"
]
},
{
"login": "Dylnuge",
"name": "Dylan Nugent",
"avatar_url": "https://avatars2.githubusercontent.com/u/118624?v=4",
"profile": "https://dylnuge.com",
"contributions": [
"content"
]
},
{
"login": "vyaslav",
"name": "vyaslav",
"avatar_url": "https://avatars0.githubusercontent.com/u/1385427?v=4",
"profile": "https://github.com/vyaslav",
"contributions": [
"code",
"content"
]
},
{
"login": "gdoenlen",
"name": "George",
"avatar_url": "https://avatars1.githubusercontent.com/u/17297466?v=4",
"profile": "https://join.sfxd.org",
"contributions": [
"code"
]
},
{
"login": "nyxtom",
"name": "Thomas Holloway",
"avatar_url": "https://avatars2.githubusercontent.com/u/222763?v=4",
"profile": "https://github.com/nyxtom",
"contributions": [
"code",
"content"
]
},
{
"login": "workingjubilee",
"name": "Jubilee",
"avatar_url": "https://avatars1.githubusercontent.com/u/46493976?v=4",
"profile": "https://github.com/workingjubilee",
"contributions": [
"code"
]
},
{
"login": "WofWca",
"name": "WofWca",
"avatar_url": "https://avatars1.githubusercontent.com/u/39462442?v=4",
"profile": "https://github.com/WofWca",
"contributions": [
"code"
]
},
{
"login": "jrvidal",
"name": "Roberto Vidal",
"avatar_url": "https://avatars0.githubusercontent.com/u/1636604?v=4",
"profile": "https://github.com/jrvidal",
"contributions": [
"code",
"doc",
"ideas",
"maintenance"
]
},
{
"login": "jensim",
"name": "Jens",
"avatar_url": "https://avatars0.githubusercontent.com/u/3663856?v=4",
"profile": "https://github.com/jensim",
"contributions": [
"doc"
]
},
{
"login": "rahatarmanahmed",
"name": "Rahat Ahmed",
"avatar_url": "https://avatars3.githubusercontent.com/u/3174006?v=4",
"profile": "http://rahatah.me/d",
"contributions": [
"doc"
]
},
{
"login": "AbdouSeck",
"name": "Abdou Seck",
"avatar_url": "https://avatars2.githubusercontent.com/u/6490055?v=4",
"profile": "https://github.com/AbdouSeck",
"contributions": [
"code",
"content",
"review"
]
},
{
"login": "codehearts",
"name": "Katie",
"avatar_url": "https://avatars0.githubusercontent.com/u/2885412?v=4",
"profile": "https://codehearts.com",
"contributions": [
"code"
]
},
{
"login": "Socratides",
"name": "Socrates",
"avatar_url": "https://avatars3.githubusercontent.com/u/27732983?v=4",
"profile": "https://github.com/Socratides",
"contributions": [
"doc"
]
},
{
"login": "gnodarse",
"name": "gnodarse",
"avatar_url": "https://avatars3.githubusercontent.com/u/46761795?v=4",
"profile": "https://github.com/gnodarse",
"contributions": [
"content"
]
},
{
"login": "harrisonmetz",
"name": "Harrison Metzger",
"avatar_url": "https://avatars1.githubusercontent.com/u/7883408?v=4",
"profile": "https://github.com/harrisonmetz",
"contributions": [
"code"
]
},
{
"login": "TorbenJ",
"name": "Torben Jonas",
"avatar_url": "https://avatars2.githubusercontent.com/u/9077102?v=4",
"profile": "https://github.com/TorbenJ",
"contributions": [
"code",
"content"
]
},
{
"login": "pbx",
"name": "Paul Bissex",
"avatar_url": "https://avatars0.githubusercontent.com/u/641?v=4",
"profile": "http://paulbissex.com/",
"contributions": [
"doc"
]
},
{
"login": "sjmann",
"name": "Steven Mann",
"avatar_url": "https://avatars0.githubusercontent.com/u/6589896?v=4",
"profile": "https://github.com/sjmann",
"contributions": [
"code",
"content"
]
},
{
"login": "Tarnadas",
"name": "Mario Reder",
"avatar_url": "https://avatars2.githubusercontent.com/u/5855071?v=4",
"profile": "https://smmdb.net/",
"contributions": [
"code",
"content"
]
},
{
"login": "sl4m",
"name": "skim",
"avatar_url": "https://avatars0.githubusercontent.com/u/47347?v=4",
"profile": "https://keybase.io/skim",
"contributions": [
"code"
]
},
{
"login": "sanjaykdragon",
"name": "Sanjay K",
"avatar_url": "https://avatars1.githubusercontent.com/u/10261698?v=4",
"profile": "https://github.com/sanjaykdragon",
"contributions": [
"code",
"content"
]
},
{
"login": "crodjer",
"name": "Rohan Jain",
"avatar_url": "https://avatars1.githubusercontent.com/u/343499?v=4",
"profile": "http://www.rohanjain.in",
"contributions": [
"code"
]
},
{
"login": "saidaspen",
"name": "Said Aspen",
"avatar_url": "https://avatars1.githubusercontent.com/u/7727687?v=4",
"profile": "https://www.saidaspen.se",
"contributions": [
"code",
"content"
]
},
{
"login": "uce",
"name": "Ufuk Celebi",
"avatar_url": "https://avatars3.githubusercontent.com/u/1756620?v=4",
"profile": "https://github.com/uce",
"contributions": [
"code"
]
},
{
"login": "lebedevsergey",
"name": "lebedevsergey",
"avatar_url": "https://avatars2.githubusercontent.com/u/7325764?v=4",
"profile": "https://github.com/lebedevsergey",
"contributions": [
"doc"
]
},
{
"login": "avrong",
"name": "Aleksei Trifonov",
"avatar_url": "https://avatars2.githubusercontent.com/u/6342851?v=4",
"profile": "https://github.com/avrong",
"contributions": [
"content"
]
},
{
"login": "Darrenmeehan",
"name": "Darren Meehan",
"avatar_url": "https://avatars2.githubusercontent.com/u/411136?v=4",
"profile": "https://drn.ie",
"contributions": [
"content"
]
},
{
"login": "jihchi",
"name": "Jihchi Lee",
"avatar_url": "https://avatars1.githubusercontent.com/u/87983?v=4",
"profile": "https://github.com/jihchi",
"contributions": [
"content"
]
},
{
"login": "bertonha",
"name": "Christofer Bertonha",
"avatar_url": "https://avatars3.githubusercontent.com/u/1225902?v=4",
"profile": "https://github.com/bertonha",
"contributions": [
"content"
]
},
{
"login": "apatniv",
"name": "Vivek Bharath Akupatni",
"avatar_url": "https://avatars2.githubusercontent.com/u/22565917?v=4",
"profile": "https://github.com/apatniv",
"contributions": [
"code",
"test"
]
},
{
"login": "DiD92",
"name": "Dídac Sementé Fernández",
"avatar_url": "https://avatars3.githubusercontent.com/u/6002416?v=4",
"profile": "https://github.com/DiD92",
"contributions": [
"code",
"content"
]
},
{
"login": "wrobstory",
"name": "Rob Story",
"avatar_url": "https://avatars3.githubusercontent.com/u/2601457?v=4",
"profile": "https://github.com/wrobstory",
"contributions": [
"code"
]
},
{
"login": "siobhanjacobson",
"name": "Siobhan Jacobson",
"avatar_url": "https://avatars2.githubusercontent.com/u/28983835?v=4",
"profile": "https://github.com/siobhanjacobson",
"contributions": [
"code"
]
},
{
"login": "EvanCarroll",
"name": "Evan Carroll",
"avatar_url": "https://avatars2.githubusercontent.com/u/19922?v=4",
"profile": "https://www.linkedin.com/in/evancarroll/",
"contributions": [
"content"
]
},
{
"login": "jmahmood",
"name": "Jawaad Mahmood",
"avatar_url": "https://avatars3.githubusercontent.com/u/95606?v=4",
"profile": "http://www.jawaadmahmood.com",
"contributions": [
"content"
]
},
{
"login": "GaurangTandon",
"name": "Gaurang Tandon",
"avatar_url": "https://avatars1.githubusercontent.com/u/6308683?v=4",
"profile": "https://github.com/GaurangTandon",
"contributions": [
"content"
]
},
{
"login": "dev-cyprium",
"name": "Stefan Kupresak",
"avatar_url": "https://avatars1.githubusercontent.com/u/6002628?v=4",
"profile": "https://github.com/dev-cyprium",
"contributions": [
"content"
]
},
{
"login": "greg-el",
"name": "Greg Leonard",
"avatar_url": "https://avatars3.githubusercontent.com/u/45019882?v=4",
"profile": "https://github.com/greg-el",
"contributions": [
"content"
]
},
{
"login": "ryanpcmcquen",
"name": "Ryan McQuen",
"avatar_url": "https://avatars3.githubusercontent.com/u/772937?v=4",
"profile": "https://ryanpcmcquen.org",
"contributions": [
"code"
]
},
{
"login": "AnnikaCodes",
"name": "Annika",
"avatar_url": "https://avatars3.githubusercontent.com/u/56906084?v=4",
"profile": "https://github.com/AnnikaCodes",
"contributions": [
"review"
]
},
{
"login": "darnuria",
"name": "Axel Viala",
"avatar_url": "https://avatars1.githubusercontent.com/u/2827553?v=4",
"profile": "https://darnuria.eu",
"contributions": [
"code"
]
},
{
"login": "sazid",
"name": "Mohammed Sazid Al Rashid",
"avatar_url": "https://avatars1.githubusercontent.com/u/2370167?v=4",
"profile": "https://sazid.github.io",
"contributions": [
"content",
"code"
]
},
{
"login": "seeplusplus",
"name": "Caleb Webber",
"avatar_url": "https://avatars1.githubusercontent.com/u/17479099?v=4",
"profile": "https://codingthemsoftly.com",
"contributions": [
"maintenance"
]
},
{
"login": "pcn",
"name": "Peter N",
"avatar_url": "https://avatars2.githubusercontent.com/u/1056756?v=4",
"profile": "https://github.com/pcn",
"contributions": [
"maintenance"
]
},
{
"login": "seancad",
"name": "seancad",
"avatar_url": "https://avatars1.githubusercontent.com/u/47405611?v=4",
"profile": "https://github.com/seancad",
"contributions": [
"maintenance"
]
},
{
"login": "wsh",
"name": "Will Hayworth",
"avatar_url": "https://avatars3.githubusercontent.com/u/181174?v=4",
"profile": "http://willhayworth.com",
"contributions": [
"content"
]
},
{
"login": "chrizel",
"name": "Christian Zeller",
"avatar_url": "https://avatars3.githubusercontent.com/u/20802?v=4",
"profile": "https://github.com/chrizel",
"contributions": [
"content"
]
},
{
"login": "jfchevrette",
"name": "Jean-Francois Chevrette",
"avatar_url": "https://avatars.githubusercontent.com/u/3001?v=4",
"profile": "https://github.com/jfchevrette",
"contributions": [
"content",
"code"
]
},
{
"login": "jbaber",
"name": "John Baber-Lucero",
"avatar_url": "https://avatars.githubusercontent.com/u/1908117?v=4",
"profile": "https://github.com/jbaber",
"contributions": [
"content"
]
},
{
"login": "tal-zvon",
"name": "Tal",
"avatar_url": "https://avatars.githubusercontent.com/u/3195851?v=4",
"profile": "https://github.com/tal-zvon",
"contributions": [
"content"
]
},
{
"login": "apogeeoak",
"name": "apogeeoak",
"avatar_url": "https://avatars.githubusercontent.com/u/59737221?v=4",
"profile": "https://github.com/apogeeoak",
"contributions": [
"content",
"code"
]
},
{
"login": "Crell",
"name": "Larry Garfield",
"avatar_url": "https://avatars.githubusercontent.com/u/254863?v=4",
"profile": "http://www.garfieldtech.com/",
"contributions": [
"content"
]
},
{
"login": "circumspect",
"name": "circumspect",
"avatar_url": "https://avatars.githubusercontent.com/u/40770208?v=4",
"profile": "https://github.com/circumspect",
"contributions": [
"content"
]
},
{
"login": "cjwyett",
"name": "Cyrus Wyett",
"avatar_url": "https://avatars.githubusercontent.com/u/34195737?v=4",
"profile": "https://github.com/cjwyett",
"contributions": [
"content"
]
},
{
"login": "cadolphs",
"name": "cadolphs",
"avatar_url": "https://avatars.githubusercontent.com/u/13894820?v=4",
"profile": "https://github.com/cadolphs",
"contributions": [
"code"
]
},
{
"login": "hpwxf",
"name": "Pascal H.",
"avatar_url": "https://avatars.githubusercontent.com/u/26146722?v=4",
"profile": "https://www.haveneer.com",
"contributions": [
"content"
]
},
{
"login": "chapeupreto",
"name": "Rod Elias",
"avatar_url": "https://avatars.githubusercontent.com/u/834048?v=4",
"profile": "https://twitter.com/chapeupreto",
"contributions": [
"content"
]
},
{
"login": "blerchy",
"name": "Matt Lebl",
"avatar_url": "https://avatars.githubusercontent.com/u/2555355?v=4",
"profile": "https://github.com/blerchy",
"contributions": [
"code"
]
},
{
"login": "flakolefluk",
"name": "Ignacio Le Fluk",
"avatar_url": "https://avatars.githubusercontent.com/u/11986564?v=4",
"profile": "http://flakolefluk.dev",
"contributions": [
"content"
]
},
{
"login": "tlyu",
"name": "Taylor Yu",
"avatar_url": "https://avatars.githubusercontent.com/u/431873?v=4",
"profile": "https://github.com/tlyu",
"contributions": [
"code",
"content"
]
},
{
"login": "Zerotask",
"name": "Patrick Hintermayer",
"avatar_url": "https://avatars.githubusercontent.com/u/20150243?v=4",
"profile": "https://zerotask.github.io",
"contributions": [
"code"
]
},
{
"login": "arthas168",
"name": "Pete Pavlovski",
"avatar_url": "https://avatars.githubusercontent.com/u/32264020?v=4",
"profile": "https://petkopavlovski.com/",
"contributions": [
"content"
]
},
{
"login": "k12ish",
"name": "k12ish",
"avatar_url": "https://avatars.githubusercontent.com/u/45272873?v=4",
"profile": "https://github.com/k12ish",
"contributions": [
"content"
]
},
{
"login": "hongshaoyang",
"name": "Shao Yang Hong",
"avatar_url": "https://avatars.githubusercontent.com/u/19281800?v=4",
"profile": "https://github.com/hongshaoyang",
"contributions": [
"content"
]
},
{
"login": "bmacer",
"name": "Brandon Macer",
"avatar_url": "https://avatars.githubusercontent.com/u/13931806?v=4",
"profile": "https://github.com/bmacer",
"contributions": [
"content"
]
},
{
"login": "stoiandan",
"name": "Stoian Dan",
"avatar_url": "https://avatars.githubusercontent.com/u/10388612?v=4",
"profile": "https://github.com/stoiandan",
"contributions": [
"content"
]
},
{
"login": "PiDelport",
"name": "Pi Delport",
"avatar_url": "https://avatars.githubusercontent.com/u/630271?v=4",
"profile": "https://about.me/pjdelport",
"contributions": [
"content"
]
},
{
"login": "sateeshkumarb",
"name": "Sateesh ",
"avatar_url": "https://avatars.githubusercontent.com/u/429263?v=4",
"profile": "https://github.com/sateeshkumarb",
"contributions": [
"code",
"content"
]
},
{
"login": "kayuapi",
"name": "ZC",
"avatar_url": "https://avatars.githubusercontent.com/u/10304328?v=4",
"profile": "https://github.com/kayuapi",
"contributions": [
"content"
]
},
{
"login": "hyperparabolic",
"name": "hyperparabolic",
"avatar_url": "https://avatars.githubusercontent.com/u/12348474?v=4",
"profile": "https://github.com/hyperparabolic",
"contributions": [
"code"
]
},
{
"login": "kolbma",
"name": "arlecchino",
"avatar_url": "https://avatars.githubusercontent.com/u/5228369?v=4",
"profile": "https://www.net4visions.at",
"contributions": [
"doc"
]
},
{
"login": "jazzplato",
"name": "Richthofen",
"avatar_url": "https://avatars.githubusercontent.com/u/7576730?v=4",
"profile": "https://richthofen.io/",
"contributions": [
"code"
]
},
{
"login": "cseltol",
"name": "Ivan Nerazumov",
"avatar_url": "https://avatars.githubusercontent.com/u/64264529?v=4",
"profile": "https://github.com/cseltol",
"contributions": [
"doc"
]
}
],
"contributorsPerLine": 8,
"projectName": "rustlings",
"projectOwner": "rust-lang",
"repoType": "github",
"repoHost": "https://github.com",
"skipCi": true
}

4
.clog.toml Normal file
View file

@ -0,0 +1,4 @@
[clog]
repository = "https://github.com/rust-lang/rustlings"
changelog = "CHANGELOG.md"

7
.editorconfig Normal file
View file

@ -0,0 +1,7 @@
root = true
[*.rs]
end_of_line = lf
insert_final_newfile = true
indent_style = space
indent_size = 4

6
.gitignore vendored
View file

@ -1,5 +1,9 @@
*.swp
target/
**/*.rs.bk
Cargo.lock
.DS_Store
*.pdb
exercises/clippy/Cargo.toml
exercises/clippy/Cargo.lock
.idea
.vscode

7
.gitpod.yml Normal file
View file

@ -0,0 +1,7 @@
tasks:
- init: /workspace/rustlings/install.sh
command: /workspace/.cargo/bin/rustlings watch
vscode:
extensions:
- rust-lang.rust@0.7.8:CvNqMTgDdt3UXt+6BCDTVg==

2
.replit Normal file
View file

@ -0,0 +1,2 @@
language = "rust"
run = "[ -x ~/.cargo/bin/rustlings ] && ~/.cargo/bin/rustlings watch || ./install.sh"

396
CHANGELOG.md Normal file
View file

@ -0,0 +1,396 @@
<a name="4.4.0"></a>
## 4.4.0 (2021-04-24)
#### Bug Fixes
* Fix spelling error in main.rs ([91ee27f2](https://github.com/rust-lang/rustlings/commit/91ee27f22bd3797a9db57e5fd430801c170c5db8))
* typo in default out text ([644c49f1](https://github.com/rust-lang/rustlings/commit/644c49f1e04cbb24e95872b3a52b07d692ae3bc8))
* **collections:** Naming exercises for vectors and hashmap ([bef39b12](https://github.com/rust-lang/rustlings/commit/bef39b125961310b34b34871e480a82e82af4678))
* **from_str:**
* Correct typos ([5f7c89f8](https://github.com/rust-lang/rustlings/commit/5f7c89f85db1f33da01911eaa479c3a2d4721678))
* test for error instead of unwrap/should_panic ([15e71535](https://github.com/rust-lang/rustlings/commit/15e71535f37cfaed36e22eb778728d186e2104ab))
* use trait objects for from_str ([c3e7b831](https://github.com/rust-lang/rustlings/commit/c3e7b831786c9172ed8bd5d150f3c432f242fba9))
* **functions3:** improve function argument type (#687) ([a6509cc4](https://github.com/rust-lang/rustlings/commit/a6509cc4d545d8825f01ddf7ee37823b372154dd))
* **hashmap2:** Update incorrect assertion (#660) ([72aaa15e](https://github.com/rust-lang/rustlings/commit/72aaa15e6ab4b72b3422f1c6356396e20a2a2bb8))
* **info:** Fix typo (#635) ([cddc1e86](https://github.com/rust-lang/rustlings/commit/cddc1e86e7ec744ee644cc774a4887b1a0ded3e8))
* **iterators2:** Moved errors out of tests. ([baf4ba17](https://github.com/rust-lang/rustlings/commit/baf4ba175ba6eb92989e3dd54ecbec4bedc9a863), closes [#359](https://github.com/rust-lang/rustlings/issues/359))
* **iterators3:** Enabled iterators3.rs to run without commented out tests. ([c6712dfc](https://github.com/rust-lang/rustlings/commit/c6712dfccd1a093e590ad22bbc4f49edc417dac0))
* **main:** Let find_exercise work with borrows ([347f30bd](https://github.com/rust-lang/rustlings/commit/347f30bd867343c5ace1097e085a1f7e356553f7))
* **move_semantics4:**
* Remove redundant "instead" (#640) ([cc266d7d](https://github.com/rust-lang/rustlings/commit/cc266d7d80b91e79df3f61984f231b7f1587218e))
* Small readbility improvement (#617) ([10965920](https://github.com/rust-lang/rustlings/commit/10965920fbdf8a1efc85bed869e55a1787006404))
* **option2:** Rename uninformative variables (#675) ([b4de6594](https://github.com/rust-lang/rustlings/commit/b4de6594380636817d13c2677ec6f472a964cf43))
* **quiz3:** Force an answer to Q2 (#672) ([0d894e6f](https://github.com/rust-lang/rustlings/commit/0d894e6ff739943901e1ae8c904582e5c2f843bd))
* **structs:** Add 5.3 to structs/README (#652) ([6bd791f2](https://github.com/rust-lang/rustlings/commit/6bd791f2f44aa7f0ad926df767f6b1fa8f12a9a9))
* **structs2:** correct grammar in hint (#663) ([ebdb66c7](https://github.com/rust-lang/rustlings/commit/ebdb66c7bfb6d687a14cc511a559a222e6fc5de4))
* **structs3:**
* reword heading comment (#664) ([9f3e8c2d](https://github.com/rust-lang/rustlings/commit/9f3e8c2dde645e5264c2d2200e68842b5f47bfa3))
* add check to prevent naive implementation of is_international ([05a753fe](https://github.com/rust-lang/rustlings/commit/05a753fe6333d36dbee5f68c21dec04eacdc75df))
* **threads1:** line number correction ([7857b0a6](https://github.com/rust-lang/rustlings/commit/7857b0a689b0847f48d8c14cbd1865e3b812d5ca))
* **try_from_into:** use trait objects ([2e93a588](https://github.com/rust-lang/rustlings/commit/2e93a588e0abe8badb7eafafb9e7d073c2be5df8))
#### Features
* Replace clap with argh ([7928122f](https://github.com/rust-lang/rustlings/commit/7928122fcef9ca7834d988b1ec8ca0687478beeb))
* Replace emojis when NO_EMOJI env variable present ([8d62a996](https://github.com/rust-lang/rustlings/commit/8d62a9963708dbecd9312e8bcc4b47049c72d155))
* Added iterators5.rs exercise. ([b29ea17e](https://github.com/rust-lang/rustlings/commit/b29ea17ea94d1862114af2cf5ced0e09c197dc35))
* **arc1:** Add more details to description and hint (#710) ([81be4044](https://github.com/rust-lang/rustlings/commit/81be40448777fa338ebced3b0bfc1b32d6370313))
* **cli:** Improve the list command with options, and then some ([8bbe4ff1](https://github.com/rust-lang/rustlings/commit/8bbe4ff1385c5c169c90cd3ff9253f9a91daaf8e))
* **list:**
* updated progress percentage ([1c6f7e4b](https://github.com/rust-lang/rustlings/commit/1c6f7e4b7b9b3bd36f4da2bb2b69c549cc8bd913))
* added progress info ([c0e3daac](https://github.com/rust-lang/rustlings/commit/c0e3daacaf6850811df5bc57fa43e0f249d5cfa4))
<a name="4.3.0"></a>
## 4.3.0 (2020-12-29)
#### Features
* Rewrite default out text ([44d39112](https://github.com/rust-lang/rustlings/commit/44d39112ff122b29c9793fe52e605df1612c6490))
* match exercise order to book chapters (#541) ([033bf119](https://github.com/rust-lang/rustlings/commit/033bf1198fc8bfce1b570e49da7cde010aa552e3))
* Crab? (#586) ([fa9f522b](https://github.com/rust-lang/rustlings/commit/fa9f522b7f043d7ef73a39f003a9272dfe72c4f4))
* add "rustlings list" command ([838f9f30](https://github.com/rust-lang/rustlings/commit/838f9f30083d0b23fd67503dcf0fbeca498e6647))
* **try_from_into:** remove duplicate annotation ([04f1d079](https://github.com/rust-lang/rustlings/commit/04f1d079aa42a2f49af694bc92c67d731d31a53f))
#### Bug Fixes
* update structs README ([bcf14cf6](https://github.com/rust-lang/rustlings/commit/bcf14cf677adb3a38a3ac3ca53f3c69f61153025))
* added missing exercises to info.toml ([90cfb6ff](https://github.com/rust-lang/rustlings/commit/90cfb6ff28377531bfc34acb70547bdb13374f6b))
* gives a bit more context to magic number ([30644c9a](https://github.com/rust-lang/rustlings/commit/30644c9a062b825c0ea89435dc59f0cad86b110e))
* **functions2:** Change signature to trigger precise error message: (#605) ([0ef95947](https://github.com/rust-lang/rustlings/commit/0ef95947cc30482e63a7045be6cc2fb6f6dcb4cc))
* **structs1:** Adjust wording (#573) ([9334783d](https://github.com/rust-lang/rustlings/commit/9334783da31d821cc59174fbe8320df95828926c))
* **try_from_into:**
* type error ([4f4cfcf3](https://github.com/rust-lang/rustlings/commit/4f4cfcf3c36c8718c7c170c9c3a6935e6ef0618c))
* Update description (#584) ([96347df9](https://github.com/rust-lang/rustlings/commit/96347df9df294f01153b29d9ad4ba361f665c755))
* **vec1:** Have test compare every element in a and v ([9b6c6293](https://github.com/rust-lang/rustlings/commit/9b6c629397b24b944f484f5b2bbd8144266b5695))
<a name="4.2.0"></a>
## 4.2.0 (2020-11-07)
#### Features
* Add HashMap exercises ([633c00cf](https://github.com/rust-lang/rustlings/commit/633c00cf8071e1e82959a3010452a32f34f29fc9))
* Add Vec exercises ([0c12fa31](https://github.com/rust-lang/rustlings/commit/0c12fa31c57c03c6287458a0a8aca7afd057baf6))
* **primitive_types6:** Add a test (#548) ([2b1fb2b7](https://github.com/rust-lang/rustlings/commit/2b1fb2b739bf9ad8d6b7b12af25fee173011bfc4))
* **try_from_into:** Add tests (#571) ([95ccd926](https://github.com/rust-lang/rustlings/commit/95ccd92616ae79ba287cce221101e0bbe4f68cdc))
#### Bug Fixes
* log error output when inotify limit is exceeded ([d61b4e5a](https://github.com/rust-lang/rustlings/commit/d61b4e5a13b44d72d004082f523fa1b6b24c1aca))
* more unique temp_file ([5643ef05](https://github.com/rust-lang/rustlings/commit/5643ef05bc81e4a840e9456f4406a769abbe1392))
* **installation:** Update the MinRustVersion ([21bfb2d4](https://github.com/rust-lang/rustlings/commit/21bfb2d4777429c87d8d3b5fbf0ce66006dcd034))
* **iterators2:** Update description (#578) ([197d3a3d](https://github.com/rust-lang/rustlings/commit/197d3a3d8961b2465579218a6749b2b2cefa8ddd))
* **primitive_types6:**
* remove 'unused doc comment' warning ([472d8592](https://github.com/rust-lang/rustlings/commit/472d8592d65c8275332a20dfc269e7ac0d41bc88))
* missing comma in test ([4fb230da](https://github.com/rust-lang/rustlings/commit/4fb230daf1251444fcf29e085cee222a91f8a37e))
* **quiz3:** Second test is for odd numbers, not even. (#553) ([18e0bfef](https://github.com/rust-lang/rustlings/commit/18e0bfef1de53071e353ba1ec5837002ff7290e6))
<a name="4.1.0"></a>
## 4.1.0 (2020-10-05)
#### Bug Fixes
* Update rustlings version in Cargo.lock ([1cc40bc9](https://github.com/rust-lang/rustlings/commit/1cc40bc9ce95c23d56f6d91fa1c4deb646231fef))
* **arc1:** index mod should equal thread count ([b4062ef6](https://github.com/rust-lang/rustlings/commit/b4062ef6993e80dac107c4093ea85166ad3ee0fa))
* **enums3:** Update Message::ChangeColor to take a tuple. (#457) ([4b6540c7](https://github.com/rust-lang/rustlings/commit/4b6540c71adabad647de8a09e57295e7c7c7d794))
* **exercises:** adding question mark to quiz2 ([101072ab](https://github.com/rust-lang/rustlings/commit/101072ab9f8c80b40b8b88cb06cbe38aca2481c5))
* **generics3:** clarify grade change ([47f7672c](https://github.com/rust-lang/rustlings/commit/47f7672c0307732056e7426e81d351f0dd7e22e5))
* **structs3:** Small adjustment of variable name ([114b54cb](https://github.com/rust-lang/rustlings/commit/114b54cbdb977234b39e5f180d937c14c78bb8b2))
* **using_as:** Add test so that proper type is returned. (#512) ([3286c5ec](https://github.com/rust-lang/rustlings/commit/3286c5ec19ea5fb7ded81d047da5f8594108a490))
#### Features
* Added iterators1.rs exercise ([9642f5a3](https://github.com/rust-lang/rustlings/commit/9642f5a3f686270a4f8f6ba969919ddbbc4f7fdd))
* Add ability to run rustlings on repl.it (#471) ([8f7b5bd0](https://github.com/rust-lang/rustlings/commit/8f7b5bd00eb83542b959830ef55192d2d76db90a))
* Add gitpod support (#473) ([4821a8be](https://github.com/rust-lang/rustlings/commit/4821a8be94af4f669042a06ab917934cfacd032f))
* Remind the user of the hint option (#425) ([816b1f5e](https://github.com/rust-lang/rustlings/commit/816b1f5e85d6cc6e72673813a85d0ada2a8f84af))
* Remind the user of the hint option (#425) ([9f61db5d](https://github.com/rust-lang/rustlings/commit/9f61db5dbe38538cf06571fcdd5f806e7901e83a))
* **cli:** Added 'cls' command to 'watch' mode (#474) ([4f2468e1](https://github.com/rust-lang/rustlings/commit/4f2468e14f574a93a2e9b688367b5752ed96ae7b))
* **try_from_into:** Add insufficient length test (#469) ([523d18b8](https://github.com/rust-lang/rustlings/commit/523d18b873a319f7c09262f44bd40e2fab1830e5))
<a name="4.0.0"></a>
## 4.0.0 (2020-07-08)
#### Breaking Changes
* Add a --nocapture option to display test harnesses' outputs ([8ad5f9bf](https://github.com/rust-lang/rustlings/commit/8ad5f9bf531a4848b1104b7b389a20171624c82f))
* Rename test to quiz, fixes #244 ([010a0456](https://github.com/rust-lang/rustlings/commit/010a04569282149cea7f7a76fc4d7f4c9f0f08dd))
#### Features
* Add traits README ([173bb141](https://github.com/rust-lang/rustlings/commit/173bb14140c5530cbdb59e53ace3991a99d804af))
* Add box1.rs exercise ([7479a473](https://github.com/rust-lang/rustlings/commit/7479a4737bdcac347322ad0883ca528c8675e720))
* Rewrite try_from_into (#393) ([763aa6e3](https://github.com/rust-lang/rustlings/commit/763aa6e378a586caae2d8d63755a85eeba227933))
* Add if2 exercise ([1da84b5f](https://github.com/rust-lang/rustlings/commit/1da84b5f7c489f65bd683c244f13c7d1ee812df0))
* Added exercise structs3.rs ([b66e2e09](https://github.com/rust-lang/rustlings/commit/b66e2e09622243e086a0f1258dd27e1a2d61c891))
* Add exercise variables6 covering const (#352) ([5999acd2](https://github.com/rust-lang/rustlings/commit/5999acd24a4f203292be36e0fd18d385887ec481))
#### Bug Fixes
* Change then to than ([ddd98ad7](https://github.com/rust-lang/rustlings/commit/ddd98ad75d3668fbb10eff74374148aa5ed2344d))
* rename quiz1 to tests1 in info (#420) ([0dd1c6ca](https://github.com/rust-lang/rustlings/commit/0dd1c6ca6b389789e0972aa955fe17aa15c95f29))
* fix quiz naming inconsistency (#421) ([5563adbb](https://github.com/rust-lang/rustlings/commit/5563adbb890587fc48fbbc9c4028642687f1e85b))
* confine the user further in variable exercises ([06ef4cc6](https://github.com/rust-lang/rustlings/commit/06ef4cc654e75d22a526812919ee49b8956280bf))
* update iterator and macro text for typos and clarity ([95900828](https://github.com/rust-lang/rustlings/commit/959008284834bece0196a01e17ac69a7e3590116))
* update generics2 closes #362 ([964c974a](https://github.com/rust-lang/rustlings/commit/964c974a0274199d755073b917c2bc5da0c9b4f1))
* confusing comment in conversions/try_from_into.rs ([c9e4f2cf](https://github.com/rust-lang/rustlings/commit/c9e4f2cfb4c48d0b7451263cfb43b9426438122d))
* **arc1:** Passively introduce attributes (#429) ([113cdae2](https://github.com/rust-lang/rustlings/commit/113cdae2d4e4c55905e8056ad326ede7fd7de356))
* **box1:** fix comment typo (#426) ([bb2ca251](https://github.com/rust-lang/rustlings/commit/bb2ca251106b27a7272d9a30872904dd1376654c))
* **errorsn:** Try harder to confine the user. (#388) ([2b20c8a0](https://github.com/rust-lang/rustlings/commit/2b20c8a0f5774d07c58d110d75879f33fc6273b5))
* **from_into.rs:** typo ([a901499e](https://github.com/rust-lang/rustlings/commit/a901499ededd3ce1995164700514fe4e9a0373ea))
* **generics2:** Guide students to the answer (#430) ([e6bd8021](https://github.com/rust-lang/rustlings/commit/e6bd8021d9a7dd06feebc30c9d5f953901d7b419))
* **installation:**
* Provide a backup git reference when tag can't be curl ([9e4fb100](https://github.com/rust-lang/rustlings/commit/9e4fb1009f1c9e3433915c03e22c2af422e5c5fe))
* Check if python is available while checking for git,rustc and cargo ([9cfb617d](https://github.com/rust-lang/rustlings/commit/9cfb617d5b0451b4b51644a1298965390cda9884))
* **option1:**
* Don't add only zeros to the numbers array ([cce6a442](https://github.com/rust-lang/rustlings/commit/cce6a4427718724a9096800754cd3abeca6a1580))
* Add cast to usize, as it is confusing in the context of an exercise about Option ([f6cffc7e](https://github.com/rust-lang/rustlings/commit/f6cffc7e487b42f15a6f958e49704c93a8d4465b))
* **option2:** Add TODO to comments (#400) ([10967bce](https://github.com/rust-lang/rustlings/commit/10967bce57682812dc0891a9f9757da1a9d87404))
* **options1:** Add hint about Array Initialization (#389) ([9f75554f](https://github.com/rust-lang/rustlings/commit/9f75554f2a30295996f03f0160b98c0458305502))
* **test2:** name of type String and &str (#394) ([d6c0a688](https://github.com/rust-lang/rustlings/commit/d6c0a688e6a96f93ad60d540d4b326f342fc0d45))
* **variables6:** minor typo (#419) ([524e17df](https://github.com/rust-lang/rustlings/commit/524e17df10db95f7b90a0f75cc8997182a8a4094))
<a name="3.0.0"></a>
## 3.0.0 (2020-04-11)
#### Breaking Changes
* make "compile" exercises print output (#278) ([3b6d5c](https://github.com/fmoko/rustlings/commit/3b6d5c3aaa27a242a832799eb66e96897d26fde3))
#### Bug Fixes
* **primitive_types:** revert primitive_types4 (#296) ([b3a3351e](https://github.com/rust-lang/rustlings/commit/b3a3351e8e6a0bdee07077d7b0382953821649ae))
* **run:** compile clippy exercise files (#295) ([3ab084a4](https://github.com/rust-lang/rustlings/commit/3ab084a421c0f140ae83bf1fc3f47b39342e7373))
* **conversions:**
* add additional test to meet exercise rules (#284) ([bc22ec3](https://github.com/fmoko/rustlings/commit/bc22ec382f843347333ef1301fc1bad773657f38))
* remove duplicate not done comment (#292) ([dab90f](https://github.com/fmoko/rustlings/commit/dab90f7b91a6000fe874e3d664f244048e5fa342))
* don't hardcode documentation version for traits (#288) ([30e6af](https://github.com/fmoko/rustlings/commit/30e6af60690c326fb5d3a9b7335f35c69c09137d))
#### Features
* add Option2 exercise (#290) ([86b5c08b](https://github.com/rust-lang/rustlings/commit/86b5c08b9bea1576127a7c5f599f5752072c087d))
* add excercise for option (#282) ([135e5d47](https://github.com/rust-lang/rustlings/commit/135e5d47a7c395aece6f6022117fb20c82f2d3d4))
* add new exercises for generics (#280) ([76be5e4e](https://github.com/rust-lang/rustlings/commit/76be5e4e991160f5fd9093f03ee2ba260e8f7229))
* **ci:** add buildkite config ([b049fa2c](https://github.com/rust-lang/rustlings/commit/b049fa2c84dba0f0c8906ac44e28fd45fba51a71))
<a name="2.2.1"></a>
### 2.2.1 (2020-02-27)
#### Bug Fixes
* Re-add cloning the repo to install scripts ([3d9b03c5](https://github.com/rust-lang/rustlings/commit/3d9b03c52b8dc51b140757f6fd25ad87b5782ef5))
#### Features
* Add clippy lints (#269) ([1e2fd9c9](https://github.com/rust-lang/rustlings/commit/1e2fd9c92f8cd6e389525ca1a999fca4c90b5921))
<a name="2.2.0"></a>
## 2.2.0 (2020-02-25)
#### Bug Fixes
* Update deps to version compatable with aarch64-pc-windows (#263) ([19a93428](https://github.com/rust-lang/rustlings/commit/19a93428b3c73d994292671f829bdc8e5b7b3401))
* **docs:**
* Added a necessary step to Windows installation process (#242) ([3906efcd](https://github.com/rust-lang/rustlings/commit/3906efcd52a004047b460ed548037093de3f523f))
* Fixed mangled sentence from book; edited for clarity (#266) ([ade52ff](https://github.com/rust-lang/rustlings/commit/ade52ffb739987287ddd5705944c8777705faed9))
* Updated iterators readme to account for iterators4 exercise (#273) ([bec8e3a](https://github.com/rust-lang/rustlings/commit/bec8e3a644cbd88db1c73ea5f1d8a364f4a34016))
* **installation:** make fatal errors more obvious (#272) ([17d0951e](https://github.com/rust-lang/rustlings/commit/17d0951e66fda8e11b204d5c4c41a0d5e22e78f7))
* **iterators2:**
* Remove reference to missing iterators2.rs (#245) ([419f7797](https://github.com/rust-lang/rustlings/commit/419f7797f294e4ce6a2b883199731b5bde77d262))
* **as_ref_mut:** Enable a test and improve per clippy's suggestion (#256) ([dfdf809](https://github.com/rust-lang/rustlings/commit/dfdf8093ebbd4145864995627b812780de52f902))
* **tests1:**
* Change test command ([fe10e06c](https://github.com/rust-lang/rustlings/commit/fe10e06c3733ddb4a21e90d09bf79bfe618e97ce)
* Correct test command in tests1.rs comment (#263) ([39fa7ae](https://github.com/rust-lang/rustlings/commit/39fa7ae8b70ad468da49b06f11b2383135a63bcf))
#### Features
* Add variables5.rs exercise (#264) ([0c73609e](https://github.com/rust-lang/rustlings/commit/0c73609e6f2311295e95d6f96f8c747cfc4cba03))
* Show a completion message when watching (#253) ([d25ee55a](https://github.com/rust-lang/rustlings/commit/d25ee55a3205882d35782e370af855051b39c58c))
* Add type conversion and parsing exercises (#249) ([0c85dc11](https://github.com/rust-lang/rustlings/commit/0c85dc1193978b5165491b99cc4922caf8d14a65))
* Created consistent money unit (#258) ([fd57f8f](https://github.com/rust-lang/rustlings/commit/fd57f8f2c1da2af8ddbebbccec214e6f40f4dbab))
* Enable test for exercise test4 (#276) ([8b971ff](https://github.com/rust-lang/rustlings/commit/8b971ffab6079a706ac925f5917f987932b55c07))
* Added traits exercises (#274 but specifically #216, which originally added
this :heart:) ([b559cdd](https://github.com/rust-lang/rustlings/commit/b559cdd73f32c0d0cfc1feda39f82b3e3583df17))
<a name="2.1.0"></a>
## 2.1.0 (2019-11-27)
#### Bug Fixes
* add line numbers in several exercises and hints ([b565c4d3](https://github.com/rust-lang/rustlings/commit/b565c4d3e74e8e110bef201a082fa1302722a7c3))
* **arc1:** Fix some words in the comment ([c42c3b21](https://github.com/rust-lang/rustlings/commit/c42c3b2101df9164c8cd7bb344def921e5ba3e61))
* **enums:** Add link to chapter on pattern syntax (#242) ([615ce327](https://github.com/rust-lang/rustlings/commit/615ce3279800c56d89f19d218ccb7ef576624feb))
* **primitive_types4:**
* update outdated hint ([4c5189df](https://github.com/rust-lang/rustlings/commit/4c5189df2bdd9a231f6b2611919ba5aa14da0d3f))
* update outdated comment ([ded2c034](https://github.com/rust-lang/rustlings/commit/ded2c034ba93fa1e3c2c2ea16b83abc1a57265e8))
* **strings2:** update line number in hint ([a09f684f](https://github.com/rust-lang/rustlings/commit/a09f684f05c58d239a6fc59ec5f81c2533e8b820))
* **variables1:** Correct wrong word in comment ([fda5a470](https://github.com/rust-lang/rustlings/commit/fda5a47069e0954f16a04e8e50945e03becb71a5))
#### Features
* **watch:** show hint while watching ([8143d57b](https://github.com/rust-lang/rustlings/commit/8143d57b4e88c51341dd4a18a14c536042cc009c))
<a name="2.0.0"></a>
## 2.0.0 (2019-11-12)
#### Bug Fixes
* **default:** Clarify the installation procedure ([c371b853](https://github.com/rust-lang/rustlings/commit/c371b853afa08947ddeebec0edd074b171eeaae0))
* **info:** Fix trailing newlines for hints ([795b6e34](https://github.com/rust-lang/rustlings/commit/795b6e348094a898e9227a14f6232f7bb94c8d31))
* **run:** make `run` never prompt ([4b265465](https://github.com/rust-lang/rustlings/commit/4b26546589f7d2b50455429482cf1f386ceae8b3))
#### Breaking Changes
* Refactor hint system ([9bdb0a12](https://github.com/rust-lang/rustlings/commit/9bdb0a12e45a8e9f9f6a4bd4a9c172c5376c7f60))
* improve `watch` execution mode ([2cdd6129](https://github.com/rust-lang/rustlings/commit/2cdd61294f0d9a53775ee24ad76435bec8a21e60))
* Index exercises by name ([627cdc07](https://github.com/rust-lang/rustlings/commit/627cdc07d07dfe6a740e885e0ddf6900e7ec336b))
* **run:** makes `run` never prompt ([4b265465](https://github.com/rust-lang/rustlings/commit/4b26546589f7d2b50455429482cf1f386ceae8b3))
#### Features
* **cli:** check for rustc before doing anything ([36a033b8](https://github.com/rust-lang/rustlings/commit/36a033b87a6549c1e5639c908bf7381c84f4f425))
* **hint:** Add test for hint ([ce9fa6eb](https://github.com/rust-lang/rustlings/commit/ce9fa6ebbfdc3e7585d488d9409797285708316f))
<a name="1.5.1"></a>
### 1.5.1 (2019-11-11)
#### Bug Fixes
* **errors3:** Update hint ([dcfb427b](https://github.com/rust-lang/rustlings/commit/dcfb427b09585f0193f0a294443fdf99f11c64cb), closes [#185](https://github.com/rust-lang/rustlings/issues/185))
* **if1:** Remove `return` reference ([ad03d180](https://github.com/rust-lang/rustlings/commit/ad03d180c9311c0093e56a3531eec1a9a70cdb45))
* **strings:** Move Strings before Structs ([6dcecb38](https://github.com/rust-lang/rustlings/commit/6dcecb38a4435593beb87c8e12d6314143631482), closes [#204](https://github.com/rust-lang/rustlings/issues/204))
* **structs1:** Remove misleading comment ([f72e5a8f](https://github.com/rust-lang/rustlings/commit/f72e5a8f05568dde04eaeac10b9a69872f21cb37))
* **threads:** Move Threads behind SLT ([fbe91a67](https://github.com/rust-lang/rustlings/commit/fbe91a67a482bfe64cbcdd58d06ba830a0f39da3), closes [#205](https://github.com/rust-lang/rustlings/issues/205))
* **watch:** clear screen before each `verify()` ([3aff590](https://github.com/rust-lang/rustlings/commit/3aff59085586c24196a547c2693adbdcf4432648))
<a name="1.5.0"></a>
## 1.5.0 (2019-11-09)
#### Bug Fixes
* **test1:** Rewrite logic ([79a56942](https://github.com/rust-lang/rustlings/commit/79a569422c8309cfc9e4aed25bf4ab3b3859996b))
* **installation:** Fix rustlings installation check ([7a252c47](https://github.com/rust-lang/rustlings/commit/7a252c475551486efb52f949b8af55803b700bc6))
* **iterators:** Rename iterator3.rs ([433d2115](https://github.com/rust-lang/rustlings/commit/433d2115bc1c04b6d34a335a18c9a8f3e2672bc6))
* **iterators2:** Remove syntax resulting in misleading error message ([4cde8664](https://github.com/rust-lang/rustlings/commit/4cde86643e12db162a66e62f23b78962986046ac))
* **option1:**
* Fix arguments passed to assert! macro (#222) ([4c2cf6da](https://github.com/rust-lang/rustlings/commit/4c2cf6da755efe02725e05ecc3a303304c10a6da))
* Fix arguments passed to assert! macro ([ead4f7af](https://github.com/rust-lang/rustlings/commit/ead4f7af9e10e53418efdde5c359159347282afd))
* Add test for prematurely passing exercise ([a750e4a1](https://github.com/rust-lang/rustlings/commit/a750e4a1a3006227292bb17d57d78ce84da6bfc6))
* **primitive_types4:** Fail on a slice covering the wrong area ([5b1e673c](https://github.com/rust-lang/rustlings/commit/5b1e673cec1658afc4ebbbc800213847804facf5))
* **readme:** http to https ([70946b85](https://github.com/rust-lang/rustlings/commit/70946b85e536e80e70ed9505cb650ca0a3a1fbb5))
* **test1:**
* Swap assertion parameter order ([4086d463](https://github.com/rust-lang/rustlings/commit/4086d463a981e81d97781851d17db2ced290f446))
* renamed function name to snake case closes #180 ([89d5186c](https://github.com/rust-lang/rustlings/commit/89d5186c0dae8135ecabf90ee8bb35949bc2d29b))
#### Features
* Add enums exercises ([dc150321](https://github.com/rust-lang/rustlings/commit/dc15032112fc485226a573a18139e5ce928b1755))
* Added exercise for struct update syntax ([1c4c8764](https://github.com/rust-lang/rustlings/commit/1c4c8764ed118740cd4cee73272ddc6cceb9d959))
* **iterators2:** adds iterators2 exercise including config ([9288fccf](https://github.com/rust-lang/rustlings/commit/9288fccf07a2c5043b76d0fd6491e4cf72d76031))
<a name="1.4.1"></a>
### 1.4.1 (2019-08-13)
#### Bug Fixes
* **iterators2:** Remove syntax resulting in misleading error message ([4cde8664](https://github.com/rust-lang/rustlings/commit/4cde86643e12db162a66e62f23b78962986046ac))
* **option1:** Add test for prematurely passing exercise ([a750e4a1](https://github.com/rust-lang/rustlings/commit/a750e4a1a3006227292bb17d57d78ce84da6bfc6))
* **test1:** Swap assertion parameter order ([4086d463](https://github.com/rust-lang/rustlings/commit/4086d463a981e81d97781851d17db2ced290f446))
<a name="1.4.0"></a>
## 1.4.0 (2019-07-13)
#### Bug Fixes
* **installation:** Fix rustlings installation check ([7a252c47](https://github.com/rust-lang/rustlings/commit/7a252c475551486efb52f949b8af55803b700bc6))
* **iterators:** Rename iterator3.rs ([433d2115](https://github.com/rust-lang/rustlings/commit/433d2115bc1c04b6d34a335a18c9a8f3e2672bc6))
* **readme:** http to https ([70946b85](https://github.com/rust-lang/rustlings/commit/70946b85e536e80e70ed9505cb650ca0a3a1fbb5))
* **test1:** renamed function name to snake case ([89d5186c](https://github.com/rust-lang/rustlings/commit/89d5186c0dae8135ecabf90ee8bb35949bc2d29b))
* **cli:** Check if changed exercise file exists before calling verify ([ba85ca3](https://github.com/rust-lang/rustlings/commit/ba85ca32c4cfc61de46851ab89f9c58a28f33c88))
* **structs1:** Fix the irrefutable let pattern warning ([cc6a141](https://github.com/rust-lang/rustlings/commit/cc6a14104d7c034eadc98297eaaa972d09c50b1f))
#### Features
* **changelog:** Use clog for changelogs ([34e31232](https://github.com/rust-lang/rustlings/commit/34e31232dfddde284a341c9609b33cd27d9d5724))
* **iterators2:** adds iterators2 exercise including config ([9288fccf](https://github.com/rust-lang/rustlings/commit/9288fccf07a2c5043b76d0fd6491e4cf72d76031))
<a name="1.3.0"></a>
### 1.3.0 (2019-06-05)
#### Features
- Adds a simple exercise for structures (#163, @briankung)
#### Bug Fixes
- Add Result type signature as it is difficult for new comers to understand Generics and Error all at once. (#157, @veggiemonk)
- Rustfmt and whitespace fixes (#161, @eddyp)
- errorsn.rs: Separate also the hints from each other to avoid accidental viewing (#162, @eddyp)
- fixed outdated links (#165, @gushroom)
- Fix broken link (#164, @HanKruiger)
- Remove highlighting and syntect (#167, @komaeda)
<a name="1.2.2"></a>
### 1.2.2 (2019-05-07)
#### Bug Fixes
- Reverted `--nocapture` flag since it was causing tests to pass unconditionally
<a name="1.2.1"></a>
### 1.2.1 (2019-04-22)
#### Bug Fixes
- Fix the `--nocapture` feature (@komaeda)
- Provide a nicer error message for when you're in the wrong directory
<a name="1.2.0"></a>
### 1.2.0 (2019-04-22)
#### Features
- Add errors to exercises that compile without user changes (@yvan-sraka)
- Use --nocapture when testing, enabling `println!` when running (@komaeda)
<a name="1.1.1"></a>
### 1.1.1 (2019-04-14)
#### Bug fixes
- Fix permissions on exercise files (@zacanger, #133)
- Make installation checks more thorough (@komaeda, 1b3469f236bc6979c27f6e1a04e4138a88e55de3)
- Fix order of true/false in tests for executables (@mgeier, #137)
- Stop run from panicking when compile fails (@cjpearce, #141)
- Fix intermittent test failure caused by race condition (@cjpearce, #140)
- Fix links by deleting book version (@diodfr, #142)
- Canonicalize paths to fix path matching (@cjpearce, #143)
<a name="1.1.0"></a>
### 1.1.0 (2019-03-20)
- errors2.rs: update link to Rust book (#124)
- Start verification at most recently modified file (#120)
- Watch for file creation events in watch mode (#117)
- Add standard library types to exercises suite (#119)
- Give a warning when Rustlings isn't run from the right directory (#123)
- Verify that rust version is recent enough to install Rustlings (#131)
<a name="1.0.1"></a>
### 1.0.1 (2019-03-06)
- Adds a way to install Rustlings in one command (`curl -L https://git.io/rustlings | bash`)
- Makes `rustlings watch` react to create file events (@shaunbennett, #117)
- Reworks the exercise management to use an external TOML file instead of just listing them in the code
<a name="1.0.0"></a>
### 1.0.0 (2019-03-06)
Initial release.

131
CONTRIBUTING.md Normal file
View file

@ -0,0 +1,131 @@
## Contributing to Rustlings
First off, thanks for taking the time to contribute!! ❤️
### Quick Reference
I want to...
_add an exercise! ➡️ [read this](#addex) and then [open a Pull Request](#prs)_
_update an outdated exercise! ➡️ [open a Pull Request](#prs)_
_report a bug! ➡️ [open an Issue](#issues)_
_fix a bug! ➡️ [open a Pull Request](#prs)_
_implement a new feature! ➡️ [open an Issue to discuss it first, then a Pull Request](#issues)_
<a name="#src"></a>
### Working on the source code
`rustlings` is basically a glorified `rustc` wrapper. Therefore the source code
isn't really that complicated since the bulk of the work is done by `rustc`.
`src/main.rs` contains a simple `clap` CLI that loads from `src/verify.rs` and `src/run.rs`.
<a name="addex"></a>
### Adding an exercise
The first step is to add the exercise! Name the file `exercises/yourTopic/yourTopicN.rs`, make sure to
put in some helpful links, and link to sections of the book in `exercises/yourTopic/README.md`.
Next make sure it runs with `rustlings`. The exercise metadata is stored in `info.toml`, under the `exercises` array. The order of the `exercises` array determines the order the exercises are run by `rustlings verify`.
Add the metadata for your exercise in the correct order in the `exercises` array. If you are unsure of the correct ordering, add it at the bottom and ask in your pull request. The exercise metadata should contain the following:
```diff
...
+ [[exercises]]
+ name = "yourTopicN"
+ path = "exercises/yourTopic/yourTopicN.rs"
+ mode = "compile"
+ hint = """
+ Some kind of useful hint for your exercise."""
...
```
The `mode` attribute decides whether Rustlings will only compile your exercise, or compile and test it. If you have tests to verify in your exercise, choose `test`, otherwise `compile`.
That's all! Feel free to put up a pull request.
<a name="issues"></a>
### Issues
You can open an issue [here](https://github.com/rust-lang/rustlings/issues/new).
If you're reporting a bug, please include the output of the following commands:
- `rustc --version`
- `rustlings --version`
- `ls -la`
- Your OS name and version
<a name="prs"></a>
### Pull Requests
Opening a pull request is as easy as forking the repository and committing your
changes. There's a couple of things to watch out for:
#### Write correct commit messages
We follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0-beta.4/)
specification, because it makes it easier to generate changelogs automatically.
This means that you have to format your commit messages in a specific way. Say
you're working on adding a new exercise called `foobar1.rs`. You could write
the following commit message:
```
feat: Add foobar1.rs exercise
```
If you're just fixing a bug, please use the `fix` type:
```
fix(verify): Make sure verify doesn't self-destruct
```
The scope within the brackets is optional, but should be any of these:
- `installation` (for the installation script)
- `cli` (for general CLI changes)
- `verify` (for the verification source file)
- `watch` (for the watch functionality source)
- `run` (for the run functionality source)
- `EXERCISENAME` (if you're changing a specific exercise, or set of exercises,
substitute them here)
When the commit also happens to close an existing issue, link it in the message
body:
```
fix: Update foobar
closes #101029908
```
If you're doing simple changes, like updating a book link, use `chore`:
```
chore: Update exercise1.rs book link
```
If you're updating documentation, use `docs`:
```
docs: Add more information to Readme
```
If, and only if, you're absolutely sure you want to make a breaking change
(please discuss this beforehand!), add an exclamation mark to the type and
explain the breaking change in the message body:
```
fix!: Completely change verification
BREAKING CHANGE: This has to be done because lorem ipsum dolor
```
#### Pull Request Workflow
Once you open a Pull Request, it may be reviewed or labeled (or both) until
the maintainers accept your change. Then, [bors](https://github.com/bors) will
run the test suite with your changes and if it's successful, automatically
merge it in!

745
Cargo.lock generated Normal file
View file

@ -0,0 +1,745 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "aho-corasick"
version = "0.7.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7404febffaa47dac81aa44dba71523c9d069b1bdc50a77db41195149e17f68e5"
dependencies = [
"memchr",
]
[[package]]
name = "argh"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "91792f088f87cdc7a2cfb1d617fa5ea18d7f1dc22ef0e1b5f82f3157cdc522be"
dependencies = [
"argh_derive",
"argh_shared",
]
[[package]]
name = "argh_derive"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c4eb0c0c120ad477412dc95a4ce31e38f2113e46bd13511253f79196ca68b067"
dependencies = [
"argh_shared",
"heck",
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "argh_shared"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "781f336cc9826dbaddb9754cb5db61e64cab4f69668bd19dcc4a0394a86f4cb1"
[[package]]
name = "assert_cmd"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2dc477793bd82ec39799b6f6b3df64938532fdf2ab0d49ef817eac65856a5a1e"
dependencies = [
"escargot",
"predicates",
"predicates-core",
"predicates-tree",
]
[[package]]
name = "atty"
version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
dependencies = [
"hermit-abi",
"libc",
"winapi 0.3.9",
]
[[package]]
name = "autocfg"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
[[package]]
name = "bitflags"
version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
[[package]]
name = "cfg-if"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
[[package]]
name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "clicolors-control"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90082ee5dcdd64dc4e9e0d37fbf3ee325419e39c0092191e0393df65518f741e"
dependencies = [
"atty",
"lazy_static",
"libc",
"winapi 0.3.9",
]
[[package]]
name = "console"
version = "0.7.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ca57c2c14b8a2bf3105bc9d15574aad80babf6a9c44b1058034cdf8bd169628"
dependencies = [
"atty",
"clicolors-control",
"encode_unicode",
"lazy_static",
"libc",
"parking_lot",
"regex",
"termios",
"unicode-width",
"winapi 0.3.9",
]
[[package]]
name = "console"
version = "0.14.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3993e6445baa160675931ec041a5e03ca84b9c6e32a056150d3aa2bdda0a1f45"
dependencies = [
"encode_unicode",
"lazy_static",
"libc",
"regex",
"terminal_size",
"unicode-width",
"winapi 0.3.9",
]
[[package]]
name = "difference"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198"
[[package]]
name = "encode_unicode"
version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f"
[[package]]
name = "escargot"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ceb9adbf9874d5d028b5e4c5739d22b71988252b25c9c98fe7cf9738bee84597"
dependencies = [
"lazy_static",
"log",
"serde",
"serde_json",
]
[[package]]
name = "filetime"
version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d34cfa13a63ae058bfa601fe9e313bbdb3746427c1459185464ce0fcf62e1e8"
dependencies = [
"cfg-if 1.0.0",
"libc",
"redox_syscall",
"winapi 0.3.9",
]
[[package]]
name = "float-cmp"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e1267f4ac4f343772758f7b1bdcbe767c218bbab93bb432acbf5162bbf85a6c4"
dependencies = [
"num-traits",
]
[[package]]
name = "fsevent"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5ab7d1bd1bd33cc98b0889831b72da23c0aa4df9cec7e0702f46ecea04b35db6"
dependencies = [
"bitflags",
"fsevent-sys",
]
[[package]]
name = "fsevent-sys"
version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f41b048a94555da0f42f1d632e2e19510084fb8e303b0daa2816e733fb3644a0"
dependencies = [
"libc",
]
[[package]]
name = "fuchsia-zircon"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82"
dependencies = [
"bitflags",
"fuchsia-zircon-sys",
]
[[package]]
name = "fuchsia-zircon-sys"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7"
[[package]]
name = "glob"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
[[package]]
name = "heck"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "87cbf45460356b7deeb5e3415b5563308c0a9b057c85e12b06ad551f98d0a6ac"
dependencies = [
"unicode-segmentation",
]
[[package]]
name = "hermit-abi"
version = "0.1.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "322f4de77956e22ed0e5032c359a0f1273f1f7f0d79bfa3b8ffbc730d7fbcc5c"
dependencies = [
"libc",
]
[[package]]
name = "indicatif"
version = "0.10.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "40ecd1e2ee08e6c255ce890f5a99d17000850e664e7acf119fb03b25b0575bfe"
dependencies = [
"console 0.14.1",
"lazy_static",
"number_prefix",
"parking_lot",
"regex",
]
[[package]]
name = "inotify"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4816c66d2c8ae673df83366c18341538f234a26d65a9ecea5c348b453ac1d02f"
dependencies = [
"bitflags",
"inotify-sys",
"libc",
]
[[package]]
name = "inotify-sys"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e05c02b5e89bff3b946cedeca278abc628fe811e604f027c45a8aa3cf793d0eb"
dependencies = [
"libc",
]
[[package]]
name = "instant"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "61124eeebbd69b8190558df225adf7e4caafce0d743919e5d6b19652314ec5ec"
dependencies = [
"cfg-if 1.0.0",
]
[[package]]
name = "iovec"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e"
dependencies = [
"libc",
]
[[package]]
name = "itoa"
version = "0.4.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736"
[[package]]
name = "kernel32-sys"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
dependencies = [
"winapi 0.2.8",
"winapi-build",
]
[[package]]
name = "lazy_static"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "lazycell"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
[[package]]
name = "libc"
version = "0.2.93"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9385f66bf6105b241aa65a61cb923ef20efc665cb9f9bb50ac2f0c4b7f378d41"
[[package]]
name = "lock_api"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a3c91c24eae6777794bb1997ad98bbb87daf92890acab859f7eaa4320333176"
dependencies = [
"scopeguard",
]
[[package]]
name = "log"
version = "0.4.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710"
dependencies = [
"cfg-if 1.0.0",
]
[[package]]
name = "memchr"
version = "2.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525"
[[package]]
name = "mio"
version = "0.6.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4afd66f5b91bf2a3bc13fad0e21caedac168ca4c707504e75585648ae80e4cc4"
dependencies = [
"cfg-if 0.1.10",
"fuchsia-zircon",
"fuchsia-zircon-sys",
"iovec",
"kernel32-sys",
"libc",
"log",
"miow",
"net2",
"slab",
"winapi 0.2.8",
]
[[package]]
name = "mio-extras"
version = "2.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "52403fe290012ce777c4626790c8951324a2b9e3316b3143779c72b029742f19"
dependencies = [
"lazycell",
"log",
"mio",
"slab",
]
[[package]]
name = "miow"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ebd808424166322d4a38da87083bfddd3ac4c131334ed55856112eb06d46944d"
dependencies = [
"kernel32-sys",
"net2",
"winapi 0.2.8",
"ws2_32-sys",
]
[[package]]
name = "net2"
version = "0.2.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "391630d12b68002ae1e25e8f974306474966550ad82dac6886fb8910c19568ae"
dependencies = [
"cfg-if 0.1.10",
"libc",
"winapi 0.3.9",
]
[[package]]
name = "normalize-line-endings"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be"
[[package]]
name = "notify"
version = "4.0.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2599080e87c9bd051ddb11b10074f4da7b1223298df65d4c2ec5bcf309af1533"
dependencies = [
"bitflags",
"filetime",
"fsevent",
"fsevent-sys",
"inotify",
"libc",
"mio",
"mio-extras",
"walkdir",
"winapi 0.3.9",
]
[[package]]
name = "num-traits"
version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290"
dependencies = [
"autocfg",
]
[[package]]
name = "number_prefix"
version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dbf9993e59c894e3c08aa1c2712914e9e6bf1fcbfc6bef283e2183df345a4fee"
dependencies = [
"num-traits",
]
[[package]]
name = "parking_lot"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d7744ac029df22dca6284efe4e898991d28e3085c706c972bcd7da4a27a15eb"
dependencies = [
"instant",
"lock_api",
"parking_lot_core",
]
[[package]]
name = "parking_lot_core"
version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa7a782938e745763fe6907fc6ba86946d72f49fe7e21de074e08128a99fb018"
dependencies = [
"cfg-if 1.0.0",
"instant",
"libc",
"redox_syscall",
"smallvec",
"winapi 0.3.9",
]
[[package]]
name = "predicates"
version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eeb433456c1a57cc93554dea3ce40b4c19c4057e41c55d4a0f3d84ea71c325aa"
dependencies = [
"difference",
"float-cmp",
"normalize-line-endings",
"predicates-core",
"regex",
]
[[package]]
name = "predicates-core"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57e35a3326b75e49aa85f5dc6ec15b41108cf5aee58eabb1f274dd18b73c2451"
[[package]]
name = "predicates-tree"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "15f553275e5721409451eb85e15fd9a860a6e5ab4496eb215987502b5f5391f2"
dependencies = [
"predicates-core",
"treeline",
]
[[package]]
name = "proc-macro2"
version = "1.0.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a152013215dca273577e18d2bf00fa862b89b24169fb78c4c95aeb07992c9cec"
dependencies = [
"unicode-xid",
]
[[package]]
name = "quote"
version = "1.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7"
dependencies = [
"proc-macro2",
]
[[package]]
name = "redox_syscall"
version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8270314b5ccceb518e7e578952f0b72b88222d02e8f77f5ecf7abbb673539041"
dependencies = [
"bitflags",
]
[[package]]
name = "regex"
version = "1.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2a26af418b574bd56588335b3a3659a65725d4e636eb1016c2f9e3b38c7cc759"
dependencies = [
"aho-corasick",
"memchr",
"regex-syntax",
]
[[package]]
name = "regex-syntax"
version = "0.6.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24d5f089152e60f62d28b835fbff2cd2e8dc0baf1ac13343bef92ab7eed84548"
[[package]]
name = "rustlings"
version = "4.4.0"
dependencies = [
"argh",
"assert_cmd",
"console 0.7.7",
"glob",
"indicatif",
"notify",
"predicates",
"regex",
"serde",
"toml",
]
[[package]]
name = "ryu"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e"
[[package]]
name = "same-file"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"
dependencies = [
"winapi-util",
]
[[package]]
name = "scopeguard"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
[[package]]
name = "serde"
version = "1.0.125"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "558dc50e1a5a5fa7112ca2ce4effcb321b0300c0d4ccf0776a9f60cd89031171"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.125"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b093b7a2bb58203b5da3056c05b4ec1fed827dcfdb37347a8841695263b3d06d"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "serde_json"
version = "1.0.64"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "799e97dc9fdae36a5c8b8f2cae9ce2ee9fdce2058c57a93e6099d919fd982f79"
dependencies = [
"itoa",
"ryu",
"serde",
]
[[package]]
name = "slab"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f173ac3d1a7e3b28003f40de0b5ce7fe2710f9b9dc3fc38664cebee46b3b6527"
[[package]]
name = "smallvec"
version = "1.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e"
[[package]]
name = "syn"
version = "1.0.70"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9505f307c872bab8eb46f77ae357c8eba1fdacead58ee5a850116b1d7f82883"
dependencies = [
"proc-macro2",
"quote",
"unicode-xid",
]
[[package]]
name = "terminal_size"
version = "0.1.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "86ca8ced750734db02076f44132d802af0b33b09942331f4459dde8636fd2406"
dependencies = [
"libc",
"winapi 0.3.9",
]
[[package]]
name = "termios"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "411c5bf740737c7918b8b1fe232dca4dc9f8e754b8ad5e20966814001ed0ac6b"
dependencies = [
"libc",
]
[[package]]
name = "toml"
version = "0.4.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "758664fc71a3a69038656bee8b6be6477d2a6c315a6b81f7081f591bffa4111f"
dependencies = [
"serde",
]
[[package]]
name = "treeline"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a7f741b240f1a48843f9b8e0444fb55fb2a4ff67293b50a9179dfd5ea67f8d41"
[[package]]
name = "unicode-segmentation"
version = "1.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb0d2e7be6ae3a5fa87eed5fb451aff96f2573d2694942e40543ae0bbe19c796"
[[package]]
name = "unicode-width"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3"
[[package]]
name = "unicode-xid"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
[[package]]
name = "walkdir"
version = "2.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56"
dependencies = [
"same-file",
"winapi 0.3.9",
"winapi-util",
]
[[package]]
name = "winapi"
version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
[[package]]
name = "winapi"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
dependencies = [
"winapi-i686-pc-windows-gnu",
"winapi-x86_64-pc-windows-gnu",
]
[[package]]
name = "winapi-build"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"
[[package]]
name = "winapi-i686-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-util"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
dependencies = [
"winapi 0.3.9",
]
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "ws2_32-sys"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e"
dependencies = [
"winapi 0.2.8",
"winapi-build",
]

View file

@ -1,12 +1,23 @@
[package]
name = "rustlings"
version = "1.0.0"
authors = ["Lynn <819880950@qq.com>", "Carol (Nichols || Goulding) <carol.nichols@gmail.com"]
version = "4.4.0"
authors = ["Marisa <mokou@posteo.de>", "Carol (Nichols || Goulding) <carol.nichols@gmail.com>"]
edition = "2018"
[dependencies]
clap = "2.32.0"
indicatif = "0.9.0"
console = "0.6.2"
syntect = "3.0.2"
notify = "4.0.0"
argh = "0.1.4"
indicatif = "0.10.3"
console = "0.7.7"
notify = "4.0.15"
toml = "0.4.10"
regex = "1.1.6"
serde = {version = "1.0.10", features = ["derive"]}
[[bin]]
name = "rustlings"
path = "src/main.rs"
[dev-dependencies]
assert_cmd = "0.11.0"
predicates = "1.0.1"
glob = "0.3.0"

122
README.md
View file

@ -1,121 +1,3 @@
![crab pet](http://i.imgur.com/LbZJgmm.gif)
# rustlings 🦀❤️
Greetings and welcome to `rustlings`. This project contains small exercises to get you used to reading and writing Rust code. This includes reading and responding to compiler messages!
_...looking for the old, web-based version of Rustlings? Try [here](https://github.com/rust-lang/rustlings/tree/rustlings-1)_
Alternatively, for a first-time Rust learner, there's several other resources:
- [The Book](https://doc.rust-lang.org/book/index.html) - The most comprehensive resource for learning Rust, but a bit theoretical sometimes. You will be using this along with Rustlings!
- [Rust By Example](https://doc.rust-lang.org/rust-by-example/index.html) - Learn Rust by solving little exercises! It's almost like `rustlings`, but online
## Getting Started
To use `rustlings` you need to have [Rust](https://www.rust-lang.org/) installed on your computer. To install Rust, go to [rustup.rs](https://rustup.rs/).
Once Rust is installed, clone the `rustlings` repository and enter the resulting directory:
```bash
git clone https://github.com/rust-lang/rustlings.git
cd rustlings
```
_Note: If you're on MacOS, make sure you've installed Xcode and its developer tools by typing `xcode-select --install`._
_Note: If you have Xcode 10+ installed, you also need to install the package file found at `/Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg`._
Once in the directory you can install `rustlings` on your machine and run the introduction:
```bash
cargo install --path .
rustlings
```
If you choose to not install the `rustlings` command, just replace `rustlings` with `cargo run` in the rest of this text.
## Doing exercises
The exercises are sorted by topic and can be found in the subdirectory `rustlings/exercises/<topic>`. For every topic there is an additional README file with some resources to get you started on the topic. We really recommend that you have a look at them before you start.
The task is simple. Most exercises contain an error that keep it from compiling, and it's up to you to fix it! Some exercises are also ran as tests, but rustlings handles them all the same. To run the exercises in the recommended order, execute:
```bash
rustlings verify
```
This will try to verify the completion of every exercise in a predetermined order (what we think is best for newcomers). If you don't want to rerun `verify` every time you change a file, you can run:
```bash
rustlings watch
```
This will do the same as verify, but won't quit after running and instead automatically rerun as soon as you change a file in the `exercises/` directory.
In case you want to go by your own order, or want to only verify a single exercise, you can run:
```bash
rustlings run exercises/path/to/exercise.rs
```
Or if it's a `#[test]`:
```bash
rustlings run --test exercises/path/to/exercise_with_test.rs
```
In case you get stuck, there is usually a hint at the bottom of each exercise.
## Testing yourself
After every couple of sections, there will be a test that'll test your knowledge on a bunch of sections at once. These tests are found in `exercises/testN.rs`.
## Completion
Rustlings isn't done; there are a couple of sections that are very experimental and don't have proper documentation. These include:
- Errors (`exercises/errors/`)
- Option (`exercises/option/`)
- Result (`exercises/result/`)
- Move Semantics (could still be improved, `exercises/move_semantics/`)
Additionally, we could use exercises on a couple of topics:
- Structs
- Better ownership stuff
- `impl`
- ??? probably more
If you are interested in improving or adding new ones, please feel free to contribute! Read on for more information :)
## Contributing
### Adding an exercise
First step is to add the exercise! Call it `exercises/yourTopic/yourTopicN.rs`, make sure to
put in some helpful links, and link to sections of the book in `exercises/yourTopic/README.md`.
Then, you'll want to make sure it gets verified when you run `rustlings verify`. Open `src/verify.rs` and
put your exercise somewhere in there:
```diff
...
compile_only("exercises/functions5.rs")?;
+ compile_only("exercises/yourTopic/yourTopicN.rs")?;
compile_only("exercises/test1.rs")?;
...
```
That's all!
### Working on the source code
`rustlings` is basically a glorified `rustc` wrapper. Therefore the source code
isn't really that complicated since the bulk of the work is done by `rustc`.
`src/main.rs` contains a simple `clap` CLI that loads from `src/verify.rs` and `src/run.rs`.
## Credits
`rustlings` was originally written by [Carol](https://github.com/carols10cents)!
# rustlings
My solutions to rustlings excercises

View file

@ -1,20 +0,0 @@
Thanks for installing `rustlings`!
## Is this your first time?
Let's make sure you're up to speed:
- You have Rust installed, preferably via `rustup`
- You have `~/.cargo/bin` added to your PATH variable
- You have cloned this repository (https://github.com/rust-lang/rustlings)
- You have installed Rust language support for your editor
- You have locally installed the `rustlings` command by running:
```sh
cargo install --path .
```
If you've done all of this (or even most of it), congrats! You're ready
to start working with Rust.
To get started, run `rustlings verify` in order to get the first exercise.
Make sure to have your editor open!

25
default_out.txt Normal file
View file

@ -0,0 +1,25 @@
Thanks for installing Rustlings!
Is this your first time? Don't worry, Rustlings was made for beginners! We are
going to teach you a lot of things about Rust, but before we can get
started, here's a couple of notes about how Rustlings operates:
1. The central concept behind Rustlings is that you solve exercises. These
exercises usually have some sort of syntax error in them, which will cause
them to fail compilation or testing. Sometimes there's a logic error instead
of a syntax error. No matter what error, it's your job to find it and fix it!
You'll know when you fixed it because then, the exercise will compile and
Rustlings will be able to move on to the next exercise.
2. If you run Rustlings in watch mode (which we recommend), it'll automatically
start with the first exercise. Don't get confused by an error message popping
up as soon as you run Rustlings! This is part of the exercise that you're
supposed to solve, so open the exercise file in an editor and start your
detective work!
3. If you're stuck on an exercise, there is a helpful hint you can view by typing
'hint' (in watch mode), or running `rustlings hint myexercise`.
4. If an exercise doesn't make sense to you, feel free to open an issue on GitHub!
(https://github.com/rust-lang/rustlings/issues/new). We look at every issue,
and sometimes, other learners do too so you can help each other out!
Got all that? Great! To get started, run `rustlings watch` in order to get the first
exercise. Make sure to have your editor open!

24
exercises/README.md Normal file
View file

@ -0,0 +1,24 @@
# Exercise to Book Chapter mapping
| Exercise | Book Chapter |
|------------------------|--------------|
| variables | §3.1 |
| functions | §3.3 |
| if | §3.5 |
| move_semantics | §4.1 |
| primitive_types | §4.3 |
| structs | §5.1 |
| enums | §6 |
| modules | §7.2 |
| collections | §8.1 |
| strings | §8.2 |
| error_handling | §9 |
| generics | §10 |
| option | §10.1 |
| traits | §10.2 |
| tests | §11.1 |
| standard_library_types | §13.2 |
| threads | §16.1 |
| macros | §19.6 |
| clippy | n/a |
| conversions | n/a |

View file

@ -0,0 +1,10 @@
# Clippy
The Clippy tool is a collection of lints to analyze your code so you can catch common mistakes and improve your Rust code.
If you used the installation script for Rustlings, Clippy should be already installed.
If not you can install it manually via `rustup component add clippy`.
## Further information
- [GitHub Repository](https://github.com/rust-lang/rust-clippy).

View file

@ -0,0 +1,17 @@
// clippy1.rs
// The Clippy tool is a collection of lints to analyze your code
// so you can catch common mistakes and improve your Rust code.
//
// For these exercises the code will fail to compile when there are clippy warnings
// check clippy's suggestions from the output to solve the exercise.
// Execute `rustlings hint clippy1` for hints :)
// I AM NOT DONE
fn main() {
let x = 1.2331f64;
let y = 1.2332f64;
if y != x {
println!("Success!");
}
}

View file

@ -0,0 +1,13 @@
// clippy2.rs
// Make me compile! Execute `rustlings hint clippy2` for hints :)
// I AM NOT DONE
fn main() {
let mut res = 42;
let option = Some(12);
for x in option {
res += x;
}
println!("{}", res);
}

View file

@ -0,0 +1,22 @@
# Collections
Rusts standard library includes a number of very useful data
structures called collections. Most other data types represent one
specific value, but collections can contain multiple values. Unlike
the built-in array and tuple types, the data these collections point
to is stored on the heap, which means the amount of data does not need
to be known at compile time and can grow or shrink as the program
runs.
This exercise will get you familiar with two fundamental data
structures that are used very often in Rust programs:
* A *vector* allows you to store a variable number of values next to
each other.
* A *hash map* allows you to associate a value with a particular key.
You may also know this by the names [*unordered map* in C++](https://en.cppreference.com/w/cpp/container/unordered_map),
[*dictionary* in Python](https://docs.python.org/3/tutorial/datastructures.html#dictionaries) or an *associative array* in other languages.
## Further information
- [Storing Lists of Values with Vectors](https://doc.rust-lang.org/stable/book/ch08-01-vectors.html)

View file

@ -0,0 +1,44 @@
// hashmap1.rs
// A basket of fruits in the form of a hash map needs to be defined.
// The key represents the name of the fruit and the value represents
// how many of that particular fruit is in the basket. You have to put
// at least three different types of fruits (e.g apple, banana, mango)
// in the basket and the total count of all the fruits should be at
// least five.
//
// Make me compile and pass the tests!
//
// Execute the command `rustlings hint hashmap1` if you need
// hints.
use std::collections::HashMap;
fn fruit_basket() -> HashMap<String, u32> {
let mut basket = HashMap::new(); // TODO: declare your hash map here.
// Two bananas are already given for you :)
basket.insert(String::from("banana"), 2);
// TODO: Put more fruits in your basket here.
basket.insert(String::from("peach"), 2);
basket.insert(String::from("mango"), 2);
basket.insert(String::from("apple"), 2);
basket
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn at_least_three_types_of_fruits() {
let basket = fruit_basket();
assert!(basket.len() >= 3);
}
#[test]
fn at_least_five_fruits() {
let basket = fruit_basket();
assert!(basket.values().sum::<u32>() >= 5);
}
}

View file

@ -0,0 +1,79 @@
// hashmap2.rs
// A basket of fruits in the form of a hash map is given. The key
// represents the name of the fruit and the value represents how many
// of that particular fruit is in the basket. You have to put *MORE
// THAN 11* fruits in the basket. Three types of fruits - Apple (4),
// Mango (2) and Lychee (5) are already given in the basket. You are
// not allowed to insert any more of these fruits!
//
// Make me pass the tests!
//
// Execute the command `rustlings hint hashmap2` if you need
// hints.
use std::collections::HashMap;
#[derive(Hash, PartialEq, Eq)]
enum Fruit {
Apple,
Banana,
Mango,
Lychee,
Pineapple,
}
fn fruit_basket(basket: &mut HashMap<Fruit, u32>) {
let fruit_kinds = vec![
Fruit::Apple,
Fruit::Banana,
Fruit::Mango,
Fruit::Lychee,
Fruit::Pineapple,
];
for fruit in fruit_kinds {
if fruit == Fruit::Banana || fruit == Fruit::Pineapple {
basket.insert(fruit, 4);
}
}
}
#[cfg(test)]
mod tests {
use super::*;
fn get_fruit_basket() -> HashMap<Fruit, u32> {
let mut basket = HashMap::<Fruit, u32>::new();
basket.insert(Fruit::Apple, 4);
basket.insert(Fruit::Mango, 2);
basket.insert(Fruit::Lychee, 5);
basket
}
#[test]
fn test_given_fruits_are_not_modified() {
let mut basket = get_fruit_basket();
fruit_basket(&mut basket);
assert_eq!(*basket.get(&Fruit::Apple).unwrap(), 4);
assert_eq!(*basket.get(&Fruit::Mango).unwrap(), 2);
assert_eq!(*basket.get(&Fruit::Lychee).unwrap(), 5);
}
#[test]
fn at_least_five_types_of_fruits() {
let mut basket = get_fruit_basket();
fruit_basket(&mut basket);
let count_fruit_kinds = basket.len();
assert!(count_fruit_kinds >= 5);
}
#[test]
fn greater_than_eleven_fruits() {
let mut basket = get_fruit_basket();
fruit_basket(&mut basket);
let count = basket.values().sum::<u32>();
assert!(count > 11);
}
}

View file

@ -0,0 +1,23 @@
// vec1.rs
// Your task is to create a `Vec` which holds the exact same elements
// as in the array `a`.
// Make me compile and pass the test!
// Execute the command `rustlings hint vec1` if you need hints.
fn array_and_vec() -> ([i32; 4], Vec<i32>) {
let a = [10, 20, 30, 40]; // a plain array
let v = vec![10,20,30,40]; // TODO: declare your vector here with the macro for vectors
(a, v)
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_array_and_vec_similarity() {
let (a, v) = array_and_vec();
assert_eq!(a, v[..]);
}
}

View file

@ -0,0 +1,35 @@
// vec2.rs
// A Vec of even numbers is given. Your task is to complete the loop
// so that each number in the Vec is multiplied by 2.
//
// Make me pass the test!
//
// Execute the command `rustlings hint vec2` if you need
// hints.
fn vec_loop(mut v: Vec<i32>) -> Vec<i32> {
for i in v.iter_mut() {
// TODO: Fill this up so that each element in the Vec `v` is
// multiplied by 2.
// *i accesses a specific object in vector?
// *= 2 multiplies it by 2
*i *= 2;
}
// At this point, `v` should be equal to [4, 8, 12, 16, 20].
v
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_vec_loop() {
let v: Vec<i32> = (1..).filter(|x| x % 2 == 0).take(5).collect();
let ans = vec_loop(v.clone());
assert_eq!(ans, v.iter().map(|x| x * 2).collect::<Vec<i32>>());
}
}

View file

@ -0,0 +1,21 @@
# Type conversions
Rust offers a multitude of ways to convert a value of a given type into another type.
The simplest form of type conversion is a type cast expression. It is denoted with the binary operator `as`. For instance, `println!("{}", 1 + 1.0);` would not compile, since `1` is an integer while `1.0` is a float. However, `println!("{}", 1 as f32 + 1.0)` should compile. The exercise [`using_as`](using_as.rs) tries to cover this.
Rust also offers traits that facilitate type conversions upon implementation. These traits can be found under the [`convert`](https://doc.rust-lang.org/std/convert/index.html) module.
The traits are the following:
- `From` and `Into` covered in [`from_into`](from_into.rs)
- `TryFrom` and `TryInto` covered in [`try_from_into`](try_from_into.rs)
- `AsRef` and `AsMut` covered in [`as_ref_mut`](as_ref_mut.rs)
Furthermore, the `std::str` module offers a trait called [`FromStr`](https://doc.rust-lang.org/std/str/trait.FromStr.html) which helps with converting strings into target types via the `parse` method on strings. If properly implemented for a given type `Person`, then `let p: Person = "Mark,20".parse().unwrap()` should both compile and run without panicking.
These should be the main ways ***within the standard library*** to convert data into your desired types.
## Further information
These are not directly covered in the book, but the standard library has a great documentation for it.
- [conversions](https://doc.rust-lang.org/std/convert/index.html)
- [`FromStr` trait](https://doc.rust-lang.org/std/str/trait.FromStr.html)

View file

@ -0,0 +1,52 @@
// AsRef and AsMut allow for cheap reference-to-reference conversions.
// Read more about them at https://doc.rust-lang.org/std/convert/trait.AsRef.html
// and https://doc.rust-lang.org/std/convert/trait.AsMut.html, respectively.
// I AM NOT DONE
// Obtain the number of bytes (not characters) in the given argument
// Add the AsRef trait appropriately as a trait bound
fn byte_counter<T>(arg: T) -> usize {
arg.as_ref().as_bytes().len()
}
// Obtain the number of characters (not bytes) in the given argument
// Add the AsRef trait appropriately as a trait bound
fn char_counter<T>(arg: T) -> usize {
arg.as_ref().chars().count()
}
fn main() {
let s = "Café au lait";
println!("{}", char_counter(s));
println!("{}", byte_counter(s));
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn different_counts() {
let s = "Café au lait";
assert_ne!(char_counter(s), byte_counter(s));
}
#[test]
fn same_counts() {
let s = "Cafe au lait";
assert_eq!(char_counter(s), byte_counter(s));
}
#[test]
fn different_counts_using_string() {
let s = String::from("Café au lait");
assert_ne!(char_counter(s.clone()), byte_counter(s));
}
#[test]
fn same_counts_using_string() {
let s = String::from("Cafe au lait");
assert_eq!(char_counter(s.clone()), byte_counter(s));
}
}

View file

@ -0,0 +1,132 @@
// The From trait is used for value-to-value conversions.
// If From is implemented correctly for a type, the Into trait should work conversely.
// You can read more about it at https://doc.rust-lang.org/std/convert/trait.From.html
#[derive(Debug)]
struct Person {
name: String,
age: usize,
}
// We implement the Default trait to use it as a fallback
// when the provided string is not convertible into a Person object
impl Default for Person {
fn default() -> Person {
Person {
name: String::from("John"),
age: 30,
}
}
}
// Your task is to complete this implementation
// in order for the line `let p = Person::from("Mark,20")` to compile
// Please note that you'll need to parse the age component into a `usize`
// with something like `"4".parse::<usize>()`. The outcome of this needs to
// be handled appropriately.
//
// Steps:
// 1. If the length of the provided string is 0, then return the default of Person
// 2. Split the given string on the commas present in it
// 3. Extract the first element from the split operation and use it as the name
// 4. If the name is empty, then return the default of Person
// 5. Extract the other element from the split operation and parse it into a `usize` as the age
// If while parsing the age, something goes wrong, then return the default of Person
// Otherwise, then return an instantiated Person object with the results
// I AM NOT DONE
impl From<&str> for Person {
fn from(s: &str) -> Person {
}
}
fn main() {
// Use the `from` function
let p1 = Person::from("Mark,20");
// Since From is implemented for Person, we should be able to use Into
let p2: Person = "Gerald,70".into();
println!("{:?}", p1);
println!("{:?}", p2);
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_default() {
// Test that the default person is 30 year old John
let dp = Person::default();
assert_eq!(dp.name, "John");
assert_eq!(dp.age, 30);
}
#[test]
fn test_bad_convert() {
// Test that John is returned when bad string is provided
let p = Person::from("");
assert_eq!(p.name, "John");
assert_eq!(p.age, 30);
}
#[test]
fn test_good_convert() {
// Test that "Mark,20" works
let p = Person::from("Mark,20");
assert_eq!(p.name, "Mark");
assert_eq!(p.age, 20);
}
#[test]
fn test_bad_age() {
// Test that "Mark,twenty" will return the default person due to an error in parsing age
let p = Person::from("Mark,twenty");
assert_eq!(p.name, "John");
assert_eq!(p.age, 30);
}
#[test]
fn test_missing_comma_and_age() {
let p: Person = Person::from("Mark");
assert_eq!(p.name, "John");
assert_eq!(p.age, 30);
}
#[test]
fn test_missing_age() {
let p: Person = Person::from("Mark,");
assert_eq!(p.name, "John");
assert_eq!(p.age, 30);
}
#[test]
fn test_missing_name() {
let p: Person = Person::from(",1");
assert_eq!(p.name, "John");
assert_eq!(p.age, 30);
}
#[test]
fn test_missing_name_and_age() {
let p: Person = Person::from(",");
assert_eq!(p.name, "John");
assert_eq!(p.age, 30);
}
#[test]
fn test_missing_name_and_invalid_age() {
let p: Person = Person::from(",one");
assert_eq!(p.name, "John");
assert_eq!(p.age, 30);
}
#[test]
fn test_trailing_comma() {
let p: Person = Person::from("Mike,32,");
assert_eq!(p.name, "John");
assert_eq!(p.age, 30);
}
#[test]
fn test_trailing_comma_and_some_string() {
let p: Person = Person::from("Mike,32,man");
assert_eq!(p.name, "John");
assert_eq!(p.age, 30);
}
}

View file

@ -0,0 +1,92 @@
// This does practically the same thing that TryFrom<&str> does.
// Additionally, upon implementing FromStr, you can use the `parse` method
// on strings to generate an object of the implementor type.
// You can read more about it at https://doc.rust-lang.org/std/str/trait.FromStr.html
use std::error;
use std::str::FromStr;
#[derive(Debug)]
struct Person {
name: String,
age: usize,
}
// I AM NOT DONE
// Steps:
// 1. If the length of the provided string is 0, an error should be returned
// 2. Split the given string on the commas present in it
// 3. Only 2 elements should be returned from the split, otherwise return an error
// 4. Extract the first element from the split operation and use it as the name
// 5. Extract the other element from the split operation and parse it into a `usize` as the age
// with something like `"4".parse::<usize>()`
// 5. If while extracting the name and the age something goes wrong, an error should be returned
// If everything goes well, then return a Result of a Person object
impl FromStr for Person {
type Err = Box<dyn error::Error>;
fn from_str(s: &str) -> Result<Person, Self::Err> {
}
}
fn main() {
let p = "Mark,20".parse::<Person>().unwrap();
println!("{:?}", p);
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn empty_input() {
assert!("".parse::<Person>().is_err());
}
#[test]
fn good_input() {
let p = "John,32".parse::<Person>();
assert!(p.is_ok());
let p = p.unwrap();
assert_eq!(p.name, "John");
assert_eq!(p.age, 32);
}
#[test]
fn missing_age() {
assert!("John,".parse::<Person>().is_err());
}
#[test]
fn invalid_age() {
assert!("John,twenty".parse::<Person>().is_err());
}
#[test]
fn missing_comma_and_age() {
assert!("John".parse::<Person>().is_err());
}
#[test]
fn missing_name() {
assert!(",1".parse::<Person>().is_err());
}
#[test]
fn missing_name_and_age() {
assert!(",".parse::<Person>().is_err());
}
#[test]
fn missing_name_and_invalid_age() {
assert!(",one".parse::<Person>().is_err());
}
#[test]
fn trailing_comma() {
assert!("John,32,".parse::<Person>().is_err());
}
#[test]
fn trailing_comma_and_some_string() {
assert!("John,32,man".parse::<Person>().is_err());
}
}

View file

@ -0,0 +1,158 @@
// TryFrom is a simple and safe type conversion that may fail in a controlled way under some circumstances.
// Basically, this is the same as From. The main difference is that this should return a Result type
// instead of the target type itself.
// You can read more about it at https://doc.rust-lang.org/std/convert/trait.TryFrom.html
use std::convert::{TryFrom, TryInto};
use std::error;
#[derive(Debug, PartialEq)]
struct Color {
red: u8,
green: u8,
blue: u8,
}
// I AM NOT DONE
// Your task is to complete this implementation
// and return an Ok result of inner type Color.
// You need to create an implementation for a tuple of three integers,
// an array of three integers and a slice of integers.
//
// Note that the implementation for tuple and array will be checked at compile time,
// but the slice implementation needs to check the slice length!
// Also note that correct RGB color values must be integers in the 0..=255 range.
// Tuple implementation
impl TryFrom<(i16, i16, i16)> for Color {
type Error = Box<dyn error::Error>;
fn try_from(tuple: (i16, i16, i16)) -> Result<Self, Self::Error> {}
}
// Array implementation
impl TryFrom<[i16; 3]> for Color {
type Error = Box<dyn error::Error>;
fn try_from(arr: [i16; 3]) -> Result<Self, Self::Error> {}
}
// Slice implementation
impl TryFrom<&[i16]> for Color {
type Error = Box<dyn error::Error>;
fn try_from(slice: &[i16]) -> Result<Self, Self::Error> {}
}
fn main() {
// Use the `from` function
let c1 = Color::try_from((183, 65, 14));
println!("{:?}", c1);
// Since From is implemented for Color, we should be able to use Into
let c2: Result<Color, _> = [183, 65, 14].try_into();
println!("{:?}", c2);
let v = vec![183, 65, 14];
// With slice we should use `from` function
let c3 = Color::try_from(&v[..]);
println!("{:?}", c3);
// or take slice within round brackets and use Into
let c4: Result<Color, _> = (&v[..]).try_into();
println!("{:?}", c4);
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_tuple_out_of_range_positive() {
assert!(Color::try_from((256, 1000, 10000)).is_err());
}
#[test]
fn test_tuple_out_of_range_negative() {
assert!(Color::try_from((-1, -10, -256)).is_err());
}
#[test]
fn test_tuple_sum() {
assert!(Color::try_from((-1, 255, 255)).is_err());
}
#[test]
fn test_tuple_correct() {
let c: Result<Color, _> = (183, 65, 14).try_into();
assert!(c.is_ok());
assert_eq!(
c.unwrap(),
Color {
red: 183,
green: 65,
blue: 14
}
);
}
#[test]
fn test_array_out_of_range_positive() {
let c: Result<Color, _> = [1000, 10000, 256].try_into();
assert!(c.is_err());
}
#[test]
fn test_array_out_of_range_negative() {
let c: Result<Color, _> = [-10, -256, -1].try_into();
assert!(c.is_err());
}
#[test]
fn test_array_sum() {
let c: Result<Color, _> = [-1, 255, 255].try_into();
assert!(c.is_err());
}
#[test]
fn test_array_correct() {
let c: Result<Color, _> = [183, 65, 14].try_into();
assert!(c.is_ok());
assert_eq!(
c.unwrap(),
Color {
red: 183,
green: 65,
blue: 14
}
);
}
#[test]
fn test_slice_out_of_range_positive() {
let arr = [10000, 256, 1000];
assert!(Color::try_from(&arr[..]).is_err());
}
#[test]
fn test_slice_out_of_range_negative() {
let arr = [-256, -1, -10];
assert!(Color::try_from(&arr[..]).is_err());
}
#[test]
fn test_slice_sum() {
let arr = [-1, 255, 255];
assert!(Color::try_from(&arr[..]).is_err());
}
#[test]
fn test_slice_correct() {
let v = vec![183, 65, 14];
let c: Result<Color, _> = Color::try_from(&v[..]);
assert!(c.is_ok());
assert_eq!(
c.unwrap(),
Color {
red: 183,
green: 65,
blue: 14
}
);
}
#[test]
fn test_slice_excess_length() {
let v = vec![0, 0, 0, 0];
assert!(Color::try_from(&v[..]).is_err());
}
#[test]
fn test_slice_insufficient_length() {
let v = vec![0, 0];
assert!(Color::try_from(&v[..]).is_err());
}
}

View file

@ -0,0 +1,28 @@
// Type casting in Rust is done via the usage of the `as` operator.
// Please note that the `as` operator is not only used when type casting.
// It also helps with renaming imports.
//
// The goal is to make sure that the division does not fail to compile
// and returns the proper type.
// I AM NOT DONE
fn average(values: &[f64]) -> f64 {
let total = values.iter().fold(0.0, |a, b| a + b);
total / values.len()
}
fn main() {
let values = [3.5, 0.3, 13.0, 11.7];
println!("{}", average(&values));
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn returns_proper_type_and_value() {
assert_eq!(average(&[3.5, 0.3, 13.0, 11.7]), 7.125);
}
}

10
exercises/enums/README.md Normal file
View file

@ -0,0 +1,10 @@
# Enums
Rust allows you to define types called "enums" which enumerate possible values.
Enums are a feature in many languages, but their capabilities differ in each language. Rusts enums are most similar to algebraic data types in functional languages, such as F#, OCaml, and Haskell.
Useful in combination with enums is Rust's "pattern matching" facility, which makes it easy to run different code for different values of an enumeration.
## Further information
- [Enums](https://doc.rust-lang.org/book/ch06-00-enums.html)
- [Pattern syntax](https://doc.rust-lang.org/book/ch18-03-pattern-syntax.html)

17
exercises/enums/enums1.rs Normal file
View file

@ -0,0 +1,17 @@
// enums1.rs
// Make me compile! Execute `rustlings hint enums1` for hints!
#[derive(Debug)]
enum Message {
Quit,
Echo,
Move,
ChangeColor
}
fn main() {
println!("{:?}", Message::Quit);
println!("{:?}", Message::Echo);
println!("{:?}", Message::Move);
println!("{:?}", Message::ChangeColor);
}

29
exercises/enums/enums2.rs Normal file
View file

@ -0,0 +1,29 @@
// enums2.rs
// Make me compile! Execute `rustlings hint enums2` for hints!
#[derive(Debug)]
enum Message {
Move { x: i32, y: i32 },
Echo(String),
ChangeColor(i32,i32,i32),
Quit
}
impl Message {
fn call(&self) {
println!("{:?}", &self);
}
}
fn main() {
let messages = [
Message::Move { x: 10, y: 30 },
Message::Echo(String::from("hello world")),
Message::ChangeColor(200, 255, 255),
Message::Quit,
];
for message in &messages {
message.call();
}
}

72
exercises/enums/enums3.rs Normal file
View file

@ -0,0 +1,72 @@
// enums3.rs
// Address all the TODOs to make the tests pass!
enum Message {
Move(Point),
Echo(String),
ChangeColor((u8,u8,u8)),
Quit
}
struct Point {
x: u8,
y: u8,
}
struct State {
color: (u8, u8, u8),
position: Point,
quit: bool,
}
impl State {
fn change_color(&mut self, color: (u8, u8, u8)) {
self.color = color;
}
fn quit(&mut self) {
self.quit = true;
}
fn echo(&self, s: String) {
println!("{}", s);
}
fn move_position(&mut self, p: Point) {
self.position = p;
}
fn process(&mut self, message: Message) {
// TODO: create a match expression to process the different message variants
match message {
Message::ChangeColor((r,g,b)) => self.change_color((r,g,b)),
Message::Echo(String) => self.echo(String),
Message::Move(Pointer) => self.move_position(Pointer),
Message::Quit => self.quit(),
_ => panic!("NOTHING SUPPLIED D:"),
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_match_message_call() {
let mut state = State {
quit: false,
position: Point { x: 0, y: 0 },
color: (0, 0, 0),
};
state.process(Message::ChangeColor((255, 0, 255)));
state.process(Message::Echo(String::from("hello world")));
state.process(Message::Move(Point { x: 10, y: 15 }));
state.process(Message::Quit);
assert_eq!(state.color, (255, 0, 255));
assert_eq!(state.position.x, 10);
assert_eq!(state.position.y, 15);
assert_eq!(state.quit, true);
}
}

View file

@ -1,5 +1,11 @@
For this exercise check out the sections:
- [Error Handling](https://doc.rust-lang.org/book/2018-edition/ch09-02-recoverable-errors-with-result.html)
- [Generics](https://doc.rust-lang.org/book/2018-edition/ch10-01-syntax.html)
# Error handling
Most errors arent serious enough to require the program to stop entirely.
Sometimes, when a function fails, its for a reason that you can easily interpret and respond to.
For example, if you try to open a file and that operation fails because the file doesnt exist, you might want to create the file instead of terminating the process.
of the Rust Book.
## Further information
- [Error Handling](https://doc.rust-lang.org/book/ch09-02-recoverable-errors-with-result.html)
- [Generics](https://doc.rust-lang.org/book/ch10-01-syntax.html)
- [Result](https://doc.rust-lang.org/rust-by-example/error/result.html)
- [Boxing errors](https://doc.rust-lang.org/rust-by-example/error/multiple_error_types/boxing_errors.html)

44
exercises/error_handling/errors1.rs Executable file → Normal file
View file

@ -4,14 +4,14 @@
// was, instead of just sometimes returning `None`. The 2nd test currently
// does not compile or pass, but it illustrates the behavior we would like
// this function to have.
// Scroll down for hints!!!
// Execute `rustlings hint errors1` for hints!
pub fn generate_nametag_text(name: String) -> Option<String> {
pub fn generate_nametag_text(name: String) -> Result<String, String> {
if name.len() > 0 {
Some(format!("Hi! My name is {}", name))
Ok(format!("Hi! My name is {}", name))
} else {
// Empty names aren't allowed.
None
Err("Empty names aren't allowed.".to_owned())
}
}
@ -26,11 +26,12 @@ mod tests {
fn generates_nametag_text_for_a_nonempty_name() {
assert_eq!(
generate_nametag_text("Beyoncé".into()),
Some("Hi! My name is Beyoncé".into())
Ok("Hi! My name is Beyoncé".into())
);
}
#[test]
#[should_panic]
fn explains_why_generating_nametag_text_fails() {
assert_eq!(
generate_nametag_text("".into()),
@ -38,36 +39,3 @@ mod tests {
);
}
}
// `Err` is one of the variants of `Result`, so what the 2nd test is saying
// is that `generate_nametag_text` should return a `Result` instead of an
// `Option`.
// To make this change, you'll need to:
// - update the return type in the function signature to be a Result that
// could be the variants `Ok(String)` and `Err(String)`
// - change the body of the function to return `Ok(stuff)` where it currently
// returns `Some(stuff)`
// - change the body of the function to return `Err(error message)` where it
// currently returns `None`
// - change the first test to expect `Ok(stuff)` where it currently expects
// `Some(stuff)`.

33
exercises/error_handling/errors2.rs Executable file → Normal file
View file

@ -14,14 +14,14 @@
// and add.
// There are at least two ways to implement this that are both correct-- but
// one is a lot shorter! Scroll down for hints to both ways.
// one is a lot shorter! Execute `rustlings hint errors2` for hints to both ways.
use std::num::ParseIntError;
pub fn total_cost(item_quantity: &str) -> Result<i32, ParseIntError> {
let processing_fee = 1;
let cost_per_item = 5;
let qty = item_quantity.parse::<i32>();
let qty = item_quantity.parse::<i32>()?;
Ok(qty * cost_per_item + processing_fee)
}
@ -32,10 +32,7 @@ mod tests {
#[test]
fn item_quantity_is_a_valid_number() {
assert_eq!(
total_cost("34"),
Ok(171)
);
assert_eq!(total_cost("34"), Ok(171));
}
#[test]
@ -46,27 +43,3 @@ mod tests {
);
}
}
// One way to handle this is using a `match` statement on
// `item_quantity.parse::<i32>()` where the cases are `Ok(something)` and
// `Err(something)`. This pattern is very common in Rust, though, so there's
// a `?` operator that does pretty much what you would make that match statement
// do for you! Take a look at this section of the Error Handling chapter:
// https://doc.rust-lang.org/stable/book/second-edition/ch09-02-recoverable-errors-with-result.html#a-shortcut-for-propagating-errors-the--operator
// and give it a try!

46
exercises/error_handling/errors3.rs Executable file → Normal file
View file

@ -1,12 +1,15 @@
// errors3.rs
// This is a program that is trying to use a completed version of the
// `total_cost` function from the previous exercise. It's not working though--
// we can't use the `?` operator in the `main()` function! Why not?
// What should we do instead? Scroll for hints!
// `total_cost` function from the previous exercise. It's not working though!
// Why not? What should we do to fix it?
// Execute `rustlings hint errors3` for hints!
use std::num::ParseIntError;
fn main() {
// In previous excercises we were taught that Result can output
// i32 and ParseIntError, but nobody told us that Result can also
// output () instead of i32... oops
fn main() -> Result<(), ParseIntError> {
let mut tokens = 100;
let pretend_user_input = "8";
@ -18,6 +21,8 @@ fn main() {
tokens -= cost;
println!("You now have {} tokens.", tokens);
}
// No need for Err() because `?` operator already handles it well
Ok(())
}
pub fn total_cost(item_quantity: &str) -> Result<i32, ParseIntError> {
@ -27,36 +32,3 @@ pub fn total_cost(item_quantity: &str) -> Result<i32, ParseIntError> {
Ok(qty * cost_per_item + processing_fee)
}
// Since the `?` operator returns an `Err` early if the thing it's trying to
// do fails, you can only use the `?` operator in functions that have a
// `Result` as their return type.
// Hence the error that you get if you run this code is:
// ```
// error[E0277]: the `?` operator can only be used in a function that returns `Result` (or another type that implements `std::ops::Try`)
// ```
// So we have to use another way of handling a `Result` within `main`.
// Decide what we should do if `pretend_user_input` has a string value that does
// not parse to an integer, and implement that instead of using the `?`
// operator.

77
exercises/error_handling/errorsn.rs Executable file → Normal file
View file

@ -2,8 +2,10 @@
// This is a bigger error exercise than the previous ones!
// You can do it! :)
//
// Edit the `read_and_validate` function so that it compiles and
// passes the tests... so many things could go wrong!
// Edit the `read_and_validate` function ONLY. Don't create any Errors
// that do not already exist.
//
// So many things could go wrong!
//
// - Reading from stdin could produce an io::Error
// - Parsing the input could produce a num::ParseIntError
@ -13,23 +15,27 @@
// type goes where the question marks are, and how do we return
// that type from the body of read_and_validate?
//
// Scroll down for hints :)
// Execute `rustlings hint errorsn` for hints :)
use std::error;
use std::fmt;
use std::io;
// PositiveNonzeroInteger is a struct defined below the tests.
fn read_and_validate(b: &mut io::BufRead) -> Result<PositiveNonzeroInteger, ???> {
fn read_and_validate(b: &mut dyn io::BufRead) -> Result<PositiveNonzeroInteger, Box<dyn error::Error>> {
let mut line = String::new();
b.read_line(&mut line);
let num: i64 = line.trim().parse();
let answer = PositiveNonzeroInteger::new(num);
answer
b.read_line(&mut line)?;
let num: i64 = line.trim().parse()?;
let answer = PositiveNonzeroInteger::new(num)?;
Ok(answer)
}
//
// Nothing below this needs to be modified
//
// This is a test helper function that turns a &str into a BufReader.
fn test_with_str(s: &str) -> Result<PositiveNonzeroInteger, Box<error::Error>> {
fn test_with_str(s: &str) -> Result<PositiveNonzeroInteger, Box<dyn error::Error>> {
let mut b = io::BufReader::new(s.as_bytes());
read_and_validate(&mut b)
}
@ -65,7 +71,7 @@ fn test_ioerror() {
assert_eq!("uh-oh!", read_and_validate(&mut b).unwrap_err().to_string());
}
#[derive(PartialEq,Debug)]
#[derive(PartialEq, Debug)]
struct PositiveNonzeroInteger(u64);
impl PositiveNonzeroInteger {
@ -83,11 +89,14 @@ impl PositiveNonzeroInteger {
#[test]
fn test_positive_nonzero_integer_creation() {
assert!(PositiveNonzeroInteger::new(10).is_ok());
assert_eq!(Err(CreationError::Negative), PositiveNonzeroInteger::new(-10));
assert_eq!(
Err(CreationError::Negative),
PositiveNonzeroInteger::new(-10)
);
assert_eq!(Err(CreationError::Zero), PositiveNonzeroInteger::new(0));
}
#[derive(PartialEq,Debug)]
#[derive(PartialEq, Debug)]
enum CreationError {
Negative,
Zero,
@ -95,44 +104,12 @@ enum CreationError {
impl fmt::Display for CreationError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str((self as &error::Error).description())
let description = match *self {
CreationError::Negative => "Number is negative",
CreationError::Zero => "Number is zero",
};
f.write_str(description)
}
}
impl error::Error for CreationError {
fn description(&self) -> &str {
match *self {
CreationError::Negative => "Negative",
CreationError::Zero => "Zero",
}
}
}
// First hint: To figure out what type should go where the ??? is, take a look
// at the test helper function `test_with_str`, since it returns whatever
// `read_and_validate` returns and`test_with_str` has its signature fully
// specified.
// Next hint: There are three places in `read_and_validate` that we call a
// function that returns a `Result` (that is, the functions might fail).
// Apply the `?` operator on those calls so that we return immediately from
// `read_and_validate` if those function calls fail.
// Another hint: under the hood, the `?` operator calls `From::from`
// on the error value to convert it to a boxed trait object, a Box<error::Error>,
// which is polymorphic-- that means that lots of different kinds of errors
// can be returned from the same function because all errors act the same
// since they all implement the `error::Error` trait.
// Check out this section of the book:
// https://doc.rust-lang.org/stable/book/second-edition/ch09-02-recoverable-errors-with-result.html#a-shortcut-for-propagating-errors-the--operator
// Another another hint: Note that because the `?` operator returns
// the *unwrapped* value in the `Ok` case, if we want to return a `Result` from
// `read_and_validate` for *its* success case, we'll have to rewrap a value
// that we got from the return value of a `?`ed call in an `Ok`-- this will
// look like `Ok(something)`.
// Another another another hint: `Result`s must be "used", that is, you'll
// get a warning if you don't handle a `Result` that you get in your
// function. Read more about that in the `std::result` module docs:
// https://doc.rust-lang.org/std/result/#results-must-be-used
impl error::Error for CreationError {}

View file

@ -1,45 +0,0 @@
// option1.rs
// This example panics because the second time it calls `pop`, the `vec`
// is empty, so `pop` returns `None`, and `unwrap` panics if it's called
// on `None`. Handle this in a more graceful way than calling `unwrap`!
// Scroll down for hints :)
fn main() {
let mut list = vec![3];
let last = list.pop().unwrap();
println!("The last item in the list is {:?}", last);
let second_to_last = list.pop().unwrap();
println!("The second-to-last item in the list is {:?}", second_to_last);
}
// Try using a `match` statement where the arms are `Some(thing)` and `None`.
// Or set a default value to print out if you get `None` by using the
// function `unwrap_or`.
// Or use an `if let` statement on the result of `pop()` to both destructure
// a `Some` value and only print out something if we have a value!

32
exercises/error_handling/result1.rs Executable file → Normal file
View file

@ -1,10 +1,12 @@
// result1.rs
// Make this test pass! Scroll down for hints :)
// Make this test pass! Execute `rustlings hint result1` for hints :)
#[derive(PartialEq,Debug)]
// I AM NOT DONE
#[derive(PartialEq, Debug)]
struct PositiveNonzeroInteger(u64);
#[derive(PartialEq,Debug)]
#[derive(PartialEq, Debug)]
enum CreationError {
Negative,
Zero,
@ -19,25 +21,9 @@ impl PositiveNonzeroInteger {
#[test]
fn test_creation() {
assert!(PositiveNonzeroInteger::new(10).is_ok());
assert_eq!(Err(CreationError::Negative), PositiveNonzeroInteger::new(-10));
assert_eq!(
Err(CreationError::Negative),
PositiveNonzeroInteger::new(-10)
);
assert_eq!(Err(CreationError::Zero), PositiveNonzeroInteger::new(0));
}
// `PositiveNonzeroInteger::new` is always creating a new instance and returning an `Ok` result.
// It should be doing some checking, returning an `Err` result if those checks fail, and only
// returning an `Ok` result if those checks determine that everything is... okay :)

View file

@ -1,7 +1,7 @@
### Functions
# Functions
Here, you'll learn how to write functions and how Rust's compiler can trace things way back.
#### Book Sections
## Further information
- [How Functions Work](https://doc.rust-lang.org/stable/book/ch03-03-how-functions-work.html)
- [How Functions Work](https://doc.rust-lang.org/book/ch03-03-how-functions-work.html)

43
exercises/functions/functions1.rs Executable file → Normal file
View file

@ -1,44 +1,9 @@
// functions1.rs
// Make me compile! Scroll down for hints :)
// Make me compile! Execute `rustlings hint functions1` for hints :)
fn main() {
call_me();
}
// This main function is calling a function that it expects to exist, but the
// function doesn't exist. It expects this function to have the name `call_me`.
// It expects this function to not take any arguments and not return a value.
// Sounds a lot like `main`, doesn't it?
fn call_me() {
println!("Called!");
}

36
exercises/functions/functions2.rs Executable file → Normal file
View file

@ -1,42 +1,12 @@
// functions2.rs
// Make me compile! Scroll down for hints :)
// Make me compile! Execute `rustlings hint functions2` for hints :)
fn main() {
call_me(3);
call_me(7);
}
fn call_me(num) {
fn call_me(num:i32) {
for i in 0..num {
println!("Ring! Call number {}", i + 1);
}
}
// Rust requires that all parts of a function's signature have type annotations,
// but `call_me` is missing the type annotation of `num`.

36
exercises/functions/functions3.rs Executable file → Normal file
View file

@ -1,42 +1,12 @@
// functions3.rs
// Make me compile! Scroll down for hints :)
// Make me compile! Execute `rustlings hint functions3` for hints :)
fn main() {
call_me();
call_me(6);
}
fn call_me(num: i32) {
fn call_me(num: u32) {
for i in 0..num {
println!("Ring! Call number {}", i + 1);
}
}
// This time, the function *declaration* is okay, but there's something wrong
// with the place where we're calling the function.

28
exercises/functions/functions4.rs Executable file → Normal file
View file

@ -1,15 +1,15 @@
// functions4.rs
// Make me compile! Scroll down for hints :)
// Make me compile! Execute `rustlings hint functions4` for hints :)
// This store is having a sale where if the price is an even number, you get
// 10 (money unit) off, but if it's an odd number, it's 3 (money unit) less.
// 10 Rustbucks off, but if it's an odd number, it's 3 Rustbucks off.
fn main() {
let original_price = 51;
println!("Your sale price is {}", sale_price(original_price));
}
fn sale_price(price: i32) -> {
fn sale_price(price: i32) -> i32 {
if is_even(price) {
price - 10
} else {
@ -20,25 +20,3 @@ fn sale_price(price: i32) -> {
fn is_even(num: i32) -> bool {
num % 2 == 0
}
// The error message points to line 12 and says it expects a type after the
// `->`. This is where the function's return type should be-- take a look at
// the `is_even` function for an example!

46
exercises/functions/functions5.rs Executable file → Normal file
View file

@ -1,47 +1,17 @@
// functions5.rs
// Make me compile! Scroll down for hints :)
// Make me compile! Execute `rustlings hint functions5` for hints :)
fn main() {
let answer = square(3);
println!("The answer is {}", answer);
}
// without ; the expression is a return statement
// it can be either both num * num or
// return num * num;
// but it cannot be
// return num * num OR num * num;
fn square(num: i32) -> i32 {
num * num;
num * num
}
// This is a really common error that can be fixed by removing one character.
// It happens because Rust distinguishes between expressions and statements: expressions return
// a value based on its operand, and statements simply return a () type which behaves just like `void` in C/C++ language.
// We want to return a value of `i32` type from the `square` function, but it is returning a `()` type...
// They are not the same. There are two solutions:
// 1. Add a `return` ahead of `num * num;`
// 2. remove `;`, make it to be `num * num`

View file

@ -0,0 +1,11 @@
# Generics
Generics is the topic of generalizing types and functionalities to broader cases.
This is extremely useful for reducing code duplication in many ways, but can call for rather involving syntax.
Namely, being generic requires taking great care to specify over which types a generic type is actually considered valid.
The simplest and most common use of generics is for type parameters.
## Further information
- [Generic Data Types](https://doc.rust-lang.org/stable/book/ch10-01-syntax.html)
- [Bounds](https://doc.rust-lang.org/rust-by-example/generics/bounds.html)

View file

@ -0,0 +1,7 @@
// This shopping list program isn't compiling!
// Use your knowledge of generics to fix it.
fn main() {
let mut shopping_list: Vec<&str> = Vec::new();
shopping_list.push("milk");
}

View file

@ -0,0 +1,27 @@
// This powerful wrapper provides the ability to store a positive integer value.
// Rewrite it using generics so that it supports wrapping ANY type.
struct Wrapper<T> {
value: T,
}
// <T> must be both for impl and Wrapper
impl<T> Wrapper<T> {
pub fn new(value: T) -> Self {
Wrapper { value }
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn store_u32_in_wrapper() {
assert_eq!(Wrapper::new(42).value, 42);
}
#[test]
fn store_str_in_wrapper() {
assert_eq!(Wrapper::new("Foo").value, "Foo");
}
}

View file

@ -0,0 +1,58 @@
// An imaginary magical school has a new report card generation system written in Rust!
// Currently the system only supports creating report cards where the student's grade
// is represented numerically (e.g. 1.0 -> 5.5).
// However, the school also issues alphabetical grades (A+ -> F-) and needs
// to be able to print both types of report card!
// Make the necessary code changes in the struct ReportCard and the impl block
// to support alphabetical report cards. Change the Grade in the second test to "A+"
// to show that your changes allow alphabetical grades.
// Execute 'rustlings hint generics3' for hints!
pub struct ReportCard<T> {
pub grade: T,
pub student_name: String,
pub student_age: u8,
}
// <T> must implement std::fmt::Display or no format!() macro
// for you
impl<T: std::fmt::Display> ReportCard<T> {
pub fn print(&self) -> String {
format!("{} ({}) - achieved a grade of {}",
&self.student_name, &self.student_age, &self.grade)
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn generate_numeric_report_card() {
let report_card = ReportCard {
grade: 2.1,
student_name: "Tom Wriggle".to_string(),
student_age: 12,
};
assert_eq!(
report_card.print(),
"Tom Wriggle (12) - achieved a grade of 2.1"
);
}
#[test]
fn generate_alphabetic_report_card() {
// TODO: Make sure to change the grade here after you finish the exercise.
let report_card = ReportCard {
grade: "A+".to_string(),
student_name: "Gary Plotter".to_string(),
student_age: 11,
};
assert_eq!(
report_card.print(),
"Gary Plotter (11) - achieved a grade of A+"
);
}
}

View file

@ -1,7 +1,7 @@
### If
# If
`if`, the most basic type of control flow, is what you'll learn here.
#### Book Sections
## Further information
- [Control Flow - if expressions](https://doc.rust-lang.org/stable/book/ch03-05-control-flow.html#if-expressions)
- [Control Flow - if expressions](https://doc.rust-lang.org/book/ch03-05-control-flow.html#if-expressions)

43
exercises/if/if1.rs Executable file → Normal file
View file

@ -1,12 +1,16 @@
// if1.rs
pub fn bigger(a: i32, b:i32) -> i32 {
// Complete this function to return the bigger number!
// Do not use:
// - return
// - another function call
// - additional variables
// Scroll down for hints.
// Execute `rustlings hint if1` for hints
pub fn bigger(a: i32, b: i32) -> i32 {
if a > b {
a
} else {
b
}
}
// Don't mind this for now :)
@ -24,36 +28,3 @@ mod tests {
assert_eq!(42, bigger(32, 42));
}
}
// It's possible to do this in one line if you would like!
// Some similar examples from other languages:
// - In C(++) this would be: `a > b ? a : b`
// - In Python this would be: `a if a > b else b`
// Remember in Rust that:
// - the `if` condition does not need to be surrounded by parentheses
// - `if`/`else` conditionals are expressions
// - Each condition is followed by a `{}` block.

37
exercises/if/if2.rs Normal file
View file

@ -0,0 +1,37 @@
// if2.rs
// Step 1: Make me compile!
// Step 2: Get the bar_for_fuzz and default_to_baz tests passing!
// Execute the command `rustlings hint if2` if you want a hint :)
pub fn fizz_if_foo(fizzish: &str) -> &str {
if fizzish == "fizz" {
"foo"
} else if fizzish == "fuzz" {
"bar"
} else {
"baz"
}
}
// No test changes needed!
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn foo_for_fizz() {
assert_eq!(fizz_if_foo("fizz"), "foo")
}
#[test]
fn bar_for_fuzz() {
assert_eq!(fizz_if_foo("fuzz"), "bar")
}
#[test]
fn default_to_baz() {
assert_eq!(fizz_if_foo("literally anything"), "baz")
}
}

View file

@ -1,10 +1,10 @@
### Macros
# Macros
Rust's macro system is very powerful, but also kind of difficult to wrap your
head around. We're not going to teach you how to write your own fully-featured
modules, instead we'll show you how to use and create them.
macros. Instead, we'll show you how to use and create them.
#### Book Sections
## Further information
- [Macros](https://doc.rust-lang.org/stable/book/ch19-06-macros.html)
- [Macros](https://doc.rust-lang.org/book/ch19-06-macros.html)
- [The Little Book of Rust Macros](https://danielkeep.github.io/tlborm/book/index.html)

56
exercises/macros/macros1.rs Executable file → Normal file
View file

@ -1,5 +1,7 @@
// macros1.rs
// Make me compile! Scroll down for hints :)
// Make me compile! Execute `rustlings hint macros1` for hints :)
// I AM NOT DONE
macro_rules! my_macro {
() => {
@ -10,55 +12,3 @@ macro_rules! my_macro {
fn main() {
my_macro();
}
// When you call a macro, you need to add something special compared to a
// regular function call. If you're stuck, take a look at what's inside
// `my_macro`.

65
exercises/macros/macros2.rs Executable file → Normal file
View file

@ -1,5 +1,7 @@
// macros2.rs
// Make me compile! Scroll down for hints :)
// Make me compile! Execute `rustlings hint macros2` for hints :)
// I AM NOT DONE
fn main() {
my_macro!();
@ -10,64 +12,3 @@ macro_rules! my_macro {
println!("Check out my macro!");
};
}
// Macros don't quite play by the same rules as the rest of Rust, in terms of
// what's available where.
// Unlike other things in Rust, the order of "where you define a macro" versus
// "where you use it" actually matters.

66
exercises/macros/macros3.rs Executable file → Normal file
View file

@ -1,5 +1,8 @@
// macros3.rs
// Make me compile, without taking the macro out of the module! Scroll down for hints :)
// Make me compile, without taking the macro out of the module!
// Execute `rustlings hint macros3` for hints :)
// I AM NOT DONE
mod macros {
macro_rules! my_macro {
@ -12,64 +15,3 @@ mod macros {
fn main() {
my_macro!();
}
// In order to use a macro outside of its module, you need to do something
// special to the module to lift the macro out into its parent.
// The same trick also works on "extern crate" statements for crates that have
// exported macros, if you've seen any of those around.

65
exercises/macros/macros4.rs Executable file → Normal file
View file

@ -1,5 +1,7 @@
// macros4.rs
// Make me compile! Scroll down for hints :)
// Make me compile! Execute `rustlings hint macros4` for hints :)
// I AM NOT DONE
macro_rules! my_macro {
() => {
@ -14,64 +16,3 @@ fn main() {
my_macro!();
my_macro!(7777);
}
// You only need to add a single character to make this compile.
// The way macros are written, it wants to see something between each
// "macro arm", so it can separate them.

View file

@ -1,7 +1,7 @@
### Modules
# Modules
In this section we'll give you an introduction to Rust's module system.
#### Book Sections
## Further information
- [The Module System](https://doc.rust-lang.org/stable/book/ch07-02-modules-and-use-to-control-scope-and-privacy.html)
- [The Module System](https://doc.rust-lang.org/book/ch07-02-defining-modules-to-control-scope-and-privacy.html)

39
exercises/modules/modules1.rs Executable file → Normal file
View file

@ -1,8 +1,12 @@
// modules1.rs
// Make me compile! Scroll down for hints :)
// Make me compile! Execute `rustlings hint modules1` for hints :)
// `mod` defines a module which can contain functions, structs etc.
// by default, its `fn`s only limited within itself, creating "closed
// ecosystem". you can make them public with `pub`
mod sausage_factory {
fn make_sausage() {
pub fn make_sausage() {
println!("sausage!");
}
}
@ -10,34 +14,3 @@ mod sausage_factory {
fn main() {
sausage_factory::make_sausage();
}
// Everything is private in Rust by default-- but there's a keyword we can use
// to make something public! The compiler error should point to the thing that
// needs to be public.

38
exercises/modules/modules2.rs Executable file → Normal file
View file

@ -1,9 +1,9 @@
// modules2.rs
// Make me compile! Scroll down for hints :)
// Make me compile! Execute `rustlings hint modules2` for hints :)
mod delicious_snacks {
use self::fruits::PEAR as fruit;
use self::veggies::CUCUMBER as veggie;
mod delicious_snacks {
pub use self::fruits::PEAR as fruit;
pub use self::veggies::CUCUMBER as veggie;
mod fruits {
pub const PEAR: &'static str = "Pear";
@ -17,29 +17,9 @@ mod delicious_snacks {
}
fn main() {
println!("favorite snacks: {} and {}",
delicious_snacks::fruit,
delicious_snacks::veggie);
println!(
"favorite snacks: {} and {}",
delicious_snacks::fruit,
delicious_snacks::veggie
);
}
// The delicious_snacks module is trying to present an external
// interface (the `fruit` and `veggie` constants) that is different than
// its internal structure (the `fruits` and `veggies` modules and
// associated constants). It's almost there except for one keyword missing for
// each constant.

View file

@ -1,10 +1,10 @@
### Move Semantics
# Move Semantics
These exercises are adapted from [pnkfelix](https://github.com/pnkfelix)'s [Rust Tutorial](https://pnkfelix.github.io/rust-examples-icfp2014/) -- Thank you Felix!!!
#### Book Sections
## Further information
For this section, the book links are especially important.
- [Ownership](https://doc.rust-lang.org/stable/book/ch04-01-what-is-ownership.html)
- [Reference and borrowing](https://doc.rust-lang.org/stable/book/ch04-02-references-and-borrowing.html)
- [Ownership](https://doc.rust-lang.org/book/ch04-01-what-is-ownership.html)
- [Reference and borrowing](https://doc.rust-lang.org/book/ch04-02-references-and-borrowing.html)

24
exercises/move_semantics/move_semantics1.rs Executable file → Normal file
View file

@ -1,17 +1,17 @@
// move_semantics1.rs
// Make me compile! Scroll down for hints :)
// Make me compile! Execute `rustlings hint move_semantics1` for hints :)
fn main() {
let vec0 = Vec::new();
let vec1 = fill_vec(vec0);
let mut vec1 = fill_vec(vec0);
println!("{} has length {} content `{:?}`", "vec1", vec1.len(), vec1);
vec1.push(88);
println!("{} has length {} content `{:?}`", "vec1", vec1.len(), vec1);
}
fn fill_vec(vec: Vec<i32>) -> Vec<i32> {
@ -23,21 +23,3 @@ fn fill_vec(vec: Vec<i32>) -> Vec<i32> {
vec
}
// So you've got the "cannot borrow immutable local variable `vec1` as mutable" error on line 11,
// right? The fix for this is going to be adding one keyword, and the addition is NOT on line 11
// where the error is.

38
exercises/move_semantics/move_semantics2.rs Executable file → Normal file
View file

@ -1,10 +1,11 @@
// move_semantics2.rs
// Make me compile without changing line 10! Scroll down for hints :)
// Make me compile without changing line 13!
// Execute `rustlings hint move_semantics2` for hints :)
fn main() {
let vec0 = Vec::new();
let mut vec1 = fill_vec(vec0);
let mut vec1 = fill_vec(&vec0);
// Do not change the following line!
println!("{} has length {} content `{:?}`", "vec0", vec0.len(), vec0);
@ -12,11 +13,10 @@ fn main() {
vec1.push(88);
println!("{} has length {} content `{:?}`", "vec1", vec1.len(), vec1);
}
fn fill_vec(vec: Vec<i32>) -> Vec<i32> {
let mut vec = vec;
fn fill_vec(vec: &[i32]) -> Vec<i32> {
let mut vec = vec.to_vec();
vec.push(22);
vec.push(44);
@ -24,31 +24,3 @@ fn fill_vec(vec: Vec<i32>) -> Vec<i32> {
vec
}
// So `vec0` is being *moved* into the function `fill_vec` when we call it on
// line 7, which means it gets dropped at the end of `fill_vec`, which means we
// can't use `vec0` again on line 10 (or anywhere else in `main` after the
// `fill_vec` call for that matter). We could fix this in a few ways, try them
// all!
// 1. Make another, separate version of the data that's in `vec0` and pass that
// to `fill_vec` instead.
// 2. Make `fill_vec` borrow its argument instead of taking ownership of it,
// and then copy the data within the function in order to return an owned
// `Vec<i32>`
// 3. Make `fill_vec` *mutably* borrow its argument (which will need to be
// mutable), modify it directly, then not return anything. Then you can get rid
// of `vec1` entirely -- note that this will change what gets printed by the
// first `println!`

29
exercises/move_semantics/move_semantics3.rs Executable file → Normal file
View file

@ -1,46 +1,25 @@
// move_semantics3.rs
// Make me compile without adding new lines-- just changing existing lines!
// (no lines with multiple semicolons necessary!)
// Scroll down for hints :)
// Execute `rustlings hint move_semantics3` for hints :)
fn main() {
let vec0 = Vec::new();
let mut vec1 = fill_vec(vec0);
let mut vec1 = fill_vec(&vec0);
println!("{} has length {} content `{:?}`", "vec1", vec1.len(), vec1);
vec1.push(88);
println!("{} has length {} content `{:?}`", "vec1", vec1.len(), vec1);
}
fn fill_vec(vec: Vec<i32>) -> Vec<i32> {
fn fill_vec(vec: &[i32]) -> Vec<i32> {
let mut vec = vec.to_vec();
vec.push(22);
vec.push(44);
vec.push(66);
vec
}
// The difference between this one and the previous ones is that the first line
// of `fn fill_vec` that had `let mut vec = vec;` is no longer there. You can,
// instead of adding that line back, add `mut` in one place that will change
// an existing binding to be a mutable binding instead of an immutable one :)

37
exercises/move_semantics/move_semantics4.rs Executable file → Normal file
View file

@ -1,23 +1,25 @@
// move_semantics4.rs
// Refactor this code so that instead of having `vec0` and creating the vector
// in `fn main`, we instead create it within `fn fill_vec` and transfer the
// freshly created vector from fill_vec to its caller. Scroll for hints!
// in `fn main`, we create it within `fn fill_vec` and transfer the
// freshly created vector from fill_vec to its caller.
// Execute `rustlings hint move_semantics4` for hints!
fn main() {
let vec0 = Vec::new();
// let vec0 = Vec::new();
let mut vec1 = fill_vec(vec0);
let mut vec1 = fill_vec();
println!("{} has length {} content `{:?}`", "vec1", vec1.len(), vec1);
vec1.push(88);
println!("{} has length {} content `{:?}`", "vec1", vec1.len(), vec1);
}
fn fill_vec(vec: Vec<i32>) -> Vec<i32> {
let mut vec = vec;
// `fill_vec()` no longer takes `vec: Vec<i32>` as argument
fn fill_vec() -> Vec<i32> {
let mut vec = Vec::new();
vec.push(22);
vec.push(44);
@ -25,24 +27,3 @@ fn fill_vec(vec: Vec<i32>) -> Vec<i32> {
vec
}
// Stop reading whenever you feel like you have enough direction :) Or try
// doing one step and then fixing the compiler errors that result!
// So the end goal is to:
// - get rid of the first line in main that creates the new vector
// - so then `vec0` doesn't exist, so we can't pass it to `fill_vec`
// - we don't want to pass anything to `fill_vec`, so its signature should
// reflect that it does not take any arguments
// - since we're not creating a new vec in `main` anymore, we need to create
// a new vec in `fill_vec`, similarly to the way we did in `main`

View file

@ -0,0 +1,18 @@
# Option
Type Option represents an optional value: every Option is either Some and contains a value, or None, and does not.
Option types are very common in Rust code, as they have a number of uses:
- Initial values
- Return values for functions that are not defined over their entire input range (partial functions)
- Return value for otherwise reporting simple errors, where None is returned on error
- Optional struct fields
- Struct fields that can be loaned or "taken"
- Optional function arguments
- Nullable pointers
- Swapping things out of difficult situations
## Further Information
- [Option Enum Format](https://doc.rust-lang.org/stable/book/ch10-01-syntax.html#in-enum-definitions)
- [Option Module Documentation](https://doc.rust-lang.org/std/option/)
- [Option Enum Documentation](https://doc.rust-lang.org/std/option/enum.Option.html)

View file

@ -0,0 +1,24 @@
// option1.rs
// Make me compile! Execute `rustlings hint option1` for hints
// I AM NOT DONE
// you can modify anything EXCEPT for this function's sig
fn print_number(maybe_number: Option<u16>) {
println!("printing: {}", maybe_number.unwrap());
}
fn main() {
// rustc suggested solutions
print_number(Some(13));
print_number(Some(99));
let numbers: [Option<u16>; 5];
for iter in 0..5 {
let number_to_add: u16 = {
((iter * 1235) + 2) / (4 * 16)
};
numbers[iter as usize] = Some(number_to_add);
}
}

View file

@ -0,0 +1,25 @@
// option2.rs
// Make me compile! Execute `rustlings hint option2` for hints
// I AM NOT DONE
fn main() {
let optional_word = Some(String::from("rustlings"));
// TODO: Make this an if let statement whose value is "Some" type
word = optional_word {
println!("The word is: {}", word);
} else {
println!("The optional word doesn't contain anything");
}
let mut optional_integers_vec: Vec<Option<i8>> = Vec::new();
for x in 1..10 {
optional_integers_vec.push(Some(x));
}
// TODO: make this a while let statement - remember that vector.pop also adds another layer of Option<T>
// You can stack `Option<T>`'s into while let and if let
integer = optional_integers_vec.pop() {
println!("current value: {}", integer);
}
}

View file

@ -1,8 +1,9 @@
### Primitive Types
# Primitive Types
Rust has a couple of basic types that are directly implemented into the
compiler. In this section, we'll go through the most important ones.
#### Book Sections
## Further information
- [Data Types](https://doc.rust-lang.org/stable/book/ch03-02-data-types.html)
- [The Slice Type](https://doc.rust-lang.org/stable/book/ch04-03-slices.html)

2
exercises/primitive_types/primitive_types1.rs Executable file → Normal file
View file

@ -10,7 +10,7 @@ fn main() {
println!("Good morning!");
}
let // Finish the rest of this line like the example! Or make it be false!
let is_evening = true; // Finish the rest of this line like the example! Or make it be false!
if is_evening {
println!("Good evening!");
}

2
exercises/primitive_types/primitive_types2.rs Executable file → Normal file
View file

@ -14,7 +14,7 @@ fn main() {
println!("Neither alphabetic nor numeric!");
}
let // Finish this line like the example! What's your favorite character?
let your_character = 'D'; // Finish this line like the example! What's your favorite character?
// Try a letter, try a number, try a special character, try a character
// from a different language than your own, try an emoji!
if your_character.is_alphabetic() {

41
exercises/primitive_types/primitive_types3.rs Executable file → Normal file
View file

@ -1,9 +1,10 @@
// primitive_types3.rs
// Create an array with at least 100 elements in it where the ??? is.
// Scroll down for hints!
// Create an array with at least 100 elements in it where the ??? is.
// Execute `rustlings hint primitive_types3` for hints!
fn main() {
let a = ???
let a: [i32; 300] = [0; 300];
if a.len() >= 100 {
println!("Wow, that's a big array!");
@ -11,37 +12,3 @@ fn main() {
println!("Meh, I eat arrays like that for breakfast.");
}
}
// There's a shorthand to initialize Arrays with a certain size that does not
// require you to type in 100 items (but you certainly can if you want!).
// For example, you can do:
// let array = ["Are we there yet?"; 10];
// Bonus: what are some other things you could have that would return true
// for `a.len() >= 100`?

49
exercises/primitive_types/primitive_types4.rs Executable file → Normal file
View file

@ -1,49 +1,12 @@
// primitive_types4.rs
// Get a slice out of Array a where the ??? is so that the `if` statement
// returns true. Scroll down for hints!!
// Get a slice out of Array a where the ??? is so that the test passes.
// Execute `rustlings hint primitive_types4` for hints!!
fn main() {
#[test]
fn slice_out_of_array() {
let a = [1, 2, 3, 4, 5];
let nice_slice = ???
let nice_slice = &a[1..4];
if nice_slice == [2, 3, 4] {
println!("Nice slice!");
} else {
println!("Not quite what I was expecting... I see: {:?}", nice_slice);
}
assert_eq!([2, 3, 4], nice_slice)
}
// Take a look at the Understanding Ownership -> Slices -> Other Slices section of the book:
// https://doc.rust-lang.org/book/ch04-03-slices.html
// and use the starting and ending indices of the items in the Array
// that you want to end up in the slice.
// If you're curious why the right hand of the `==` comparison does not
// have an ampersand for a reference since the left hand side is a
// reference, take a look at the Deref coercions section of the book:
// https://doc.rust-lang.org/book/ch15-02-deref.html

39
exercises/primitive_types/primitive_types5.rs Executable file → Normal file
View file

@ -1,45 +1,10 @@
// primitive_types5.rs
// Destructure the `cat` tuple so that the println will work.
// Scroll down for hints!
// Execute `rustlings hint primitive_types5` for hints!
fn main() {
let cat = ("Furry McFurson", 3.5);
let /* your pattern here */ = cat;
let (name, age) = cat;
println!("{} is {} years old.", name, age);
}
// Take a look at the Data Types -> The Tuple Type section of the book:
// https://doc.rust-lang.org/stable/book/ch03-02-data-types.html#the-tuple-type
// Particularly the part about destructuring (second to last example in the section).
// You'll need to make a pattern to bind `name` and `age` to the appropriate parts
// of the tuple. You can do it!!

50
exercises/primitive_types/primitive_types6.rs Executable file → Normal file
View file

@ -1,45 +1,13 @@
// primitive_types6.rs
// Use a tuple index to access the second element of `numbers`.
// You can put this right into the `println!` where the ??? is.
// Scroll down for hints!
fn main() {
// You can put the expression for the second element where ??? is so that the test passes.
// Execute `rustlings hint primitive_types6` for hints!
#[test]
fn indexing_tuple() {
let numbers = (1, 2, 3);
println!("The second number is {}", ???);
// Replace below ??? with the tuple indexing syntax.
let second = numbers.1;
assert_eq!(2, second,
"This is not the 2nd number in the tuple!")
}
// While you could use a destructuring `let` for the tuple here, try
// indexing into it instead, as explained in the last example of the
// Data Types -> The Tuple Type section of the book:
// https://doc.rust-lang.org/stable/book/ch03-02-data-types.html#the-tuple-type
// Now you have another tool in your toolbox!

29
exercises/quiz1.rs Normal file
View file

@ -0,0 +1,29 @@
// quiz1.rs
// This is a quiz for the following sections:
// - Variables
// - Functions
// Mary is buying apples. One apple usually costs 2 Rustbucks, but if you buy
// more than 40 at once, each apple only costs 1! Write a function that calculates
// the price of an order of apples given the order amount. No hints this time!
// Put your function here!
// fn ..... {
fn calculate_apple_price(amount: i32) -> i32 {
if amount > 40 {
1 * amount
} else {
2 * amount
}
}
// Don't modify this function!
#[test]
fn verify_test() {
let price1 = calculate_apple_price(35);
let price2 = calculate_apple_price(65);
assert_eq!(70, price1);
assert_eq!(65, price2);
}

28
exercises/quiz2.rs Normal file
View file

@ -0,0 +1,28 @@
// quiz2.rs
// This is a quiz for the following sections:
// - Strings
// Ok, here are a bunch of values-- some are `String`s, some are `&str`s. Your
// task is to call one of these two functions on each value depending on what
// you think each value is. That is, add either `string_slice` or `string`
// before the parentheses on each line. If you're right, it will compile!
fn string_slice(arg: &str) {
println!("{}", arg);
}
fn string(arg: String) {
println!("{}", arg);
}
fn main() {
string_slice("blue");
string("red".to_string());
string(String::from("hi"));
string("rust is fun!".to_owned());
string("nice weather".into());
string(format!("Interpolation {}", "Station"));
string_slice(&String::from("abc")[0..1]);
string_slice(" hello there ".trim());
string("Happy Monday!".to_string().replace("Mon", "Tues"));
string("mY sHiFt KeY iS sTiCkY".to_lowercase());
}

16
exercises/test2.rs → exercises/quiz3.rs Executable file → Normal file
View file

@ -1,12 +1,14 @@
// test2.rs
// This is a test for the following sections:
// quiz3.rs
// This is a quiz for the following sections:
// - Tests
// This test isn't testing our function -- make it do that in such a way that
// This quiz isn't testing our function -- make it do that in such a way that
// the test passes. Then write a second test that tests that we get the result
// we expect to get when we call `times_two` with a negative number.
// No hints, you can do this :)
// I AM NOT DONE
pub fn times_two(num: i32) -> i32 {
num * 2
}
@ -17,6 +19,12 @@ mod tests {
#[test]
fn returns_twice_of_positive_numbers() {
assert_eq!(4, 4);
assert_eq!(times_two(4), ???);
}
#[test]
fn returns_twice_of_negative_numbers() {
// TODO replace unimplemented!() with an assert for `times_two(-4)`
unimplemented!()
}
}

23
exercises/quiz4.rs Normal file
View file

@ -0,0 +1,23 @@
// quiz4.rs
// This quiz covers the sections:
// - Modules
// - Macros
// Write a macro that passes the quiz! No hints this time, you can do it!
// I AM NOT DONE
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_my_macro_world() {
assert_eq!(my_macro!("world!"), "Hello world!");
}
#[test]
fn test_my_macro_goodbye() {
assert_eq!(my_macro!("goodbye!"), "Hello goodbye!");
}
}

View file

@ -1,5 +1,10 @@
For the Arc exercise check out the chapter [Shared-State Concurrency](https://doc.rust-lang.org/book/2018-edition/ch16-03-shared-state.html) of the Rust Book.
# Standard library types
For the Iterator exercise check out the chapters [Iterator](https://doc.rust-lang.org/book/2018-edition/ch13-02-iterators.html) of the Rust Book and the [Iterator documentation](https://doc.rust-lang.org/stable/std/iter/trait.Iterator.htmlj).
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!
This section will teach you about Box, Shared-State Concurrency and Iterators.
## Further information
- [Using Box to Point to Data on the Heap](https://doc.rust-lang.org/book/ch15-01-box.html)
- [Shared-State Concurrency](https://doc.rust-lang.org/book/ch16-03-shared-state.html)
- [Iterator](https://doc.rust-lang.org/book/ch13-02-iterators.html)
- [Iterator documentation](https://doc.rust-lang.org/stable/std/iter/)

57
exercises/standard_library_types/arc1.rs Executable file → Normal file
View file

@ -1,9 +1,26 @@
// arc1.rs
// Make this code compile by filling in a value for `shared_numbers` where the
// TODO comment is and creating an initial binding for `child_numbers`
// somewhere. Try not to create any copies of the `numbers` Vec!
// Scroll down for hints :)
// In this exercise, we are given a Vec of u32 called "numbers" with values ranging
// from 0 to 99 -- [ 0, 1, 2, ..., 98, 99 ]
// We would like to use this set of numbers within 8 different threads simultaneously.
// Each thread is going to get the sum of every eighth value, with an offset.
// The first thread (offset 0), will sum 0, 8, 16, ...
// The second thread (offset 1), will sum 1, 9, 17, ...
// The third thread (offset 2), will sum 2, 10, 18, ...
// ...
// The eighth thread (offset 7), will sum 7, 15, 23, ...
// Because we are using threads, our values need to be thread-safe. Therefore,
// we are using Arc. We need to make a change in each of the two TODOs.
// Make this code compile by filling in a value for `shared_numbers` where the
// first TODO comment is, and create an initial binding for `child_numbers`
// where the second TODO comment is. Try not to create any copies of the `numbers` Vec!
// Execute `rustlings hint arc1` for hints :)
// I AM NOT DONE
#![forbid(unused_imports)] // Do not change this, (or the next) line.
use std::sync::Arc;
use std::thread;
@ -13,13 +30,13 @@ fn main() {
let mut joinhandles = Vec::new();
for offset in 0..8 {
joinhandles.push(
thread::spawn(move || {
let child_numbers = // TODO
joinhandles.push(thread::spawn(move || {
let mut i = offset;
let mut sum = 0;
while i < child_numbers.len() {
sum += child_numbers[i];
i += 5;
i += 8;
}
println!("Sum of offset {} is {}", offset, sum);
}));
@ -28,29 +45,3 @@ fn main() {
handle.join().unwrap();
}
}
// Make `shared_numbers` be an `Arc` from the numbers vector. Then, in order
// to avoid creating a copy of `numbers`, you'll need to create `child_numbers`
// inside the loop but still in the main thread.
// `child_numbers` should be a clone of the Arc of the numbers instead of a
// thread-local copy of the numbers.

View file

@ -0,0 +1,56 @@
// box1.rs
//
// At compile time, Rust needs to know how much space a type takes up. This becomes problematic
// for recursive types, where a value can have as part of itself another value of the same type.
// To get around the issue, we can use a `Box` - a smart pointer used to store data on the heap,
// which also allows us to wrap a recursive type.
//
// The recursive type we're implementing in this exercise is the `cons list` - a data structure
// frequently found in functional programming languages. Each item in a cons list contains two
// elements: the value of the current item and the next item. The last item is a value called `Nil`.
//
// Step 1: use a `Box` in the enum definition to make the code compile
// Step 2: create both empty and non-empty cons lists by replacing `unimplemented!()`
//
// Note: the tests should not be changed
//
// Execute `rustlings hint box1` for hints :)
// I AM NOT DONE
#[derive(PartialEq, Debug)]
pub enum List {
Cons(i32, List),
Nil,
}
fn main() {
println!("This is an empty cons list: {:?}", create_empty_list());
println!(
"This is a non-empty cons list: {:?}",
create_non_empty_list()
);
}
pub fn create_empty_list() -> List {
unimplemented!()
}
pub fn create_non_empty_list() -> List {
unimplemented!()
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_create_empty_list() {
assert_eq!(List::Nil, create_empty_list())
}
#[test]
fn test_create_non_empty_list() {
assert_ne!(create_empty_list(), create_non_empty_list())
}
}

View file

@ -1,147 +0,0 @@
// iterator3.rs
// This is a bigger exercise than most of the others! You can do it!
// Here is your mission, should you choose to accept it:
// 1. Complete the divide function to get the first four tests to pass
// 2. Uncomment the last two tests and get them to pass by filling in
// values for `x` using `division_results`.
// Scroll down for a minor hint for part 2, and scroll down further for
// a major hint.
// Have fun :-)
#[derive(Debug, PartialEq, Eq)]
pub enum DivisionError {
NotDivisible(NotDivisibleError),
DivideByZero,
}
#[derive(Debug, PartialEq, Eq)]
pub struct NotDivisibleError {
dividend: i32,
divisor: i32,
}
// This function should calculate `a` divided by `b` if `a` is
// evenly divisible by b.
// Otherwise, it should return a suitable error.
pub fn divide(a: i32, b: i32) -> Result<i32, DivisionError> {
}
#[cfg(test)]
mod tests {
use super::*;
// Tests that verify your `divide` function implementation
#[test]
fn test_success() {
assert_eq!(divide(81, 9), Ok(9));
}
#[test]
fn test_not_divisible() {
assert_eq!(
divide(81, 6),
Err(DivisionError::NotDivisible(NotDivisibleError{
dividend: 81,
divisor: 6
}))
);
}
#[test]
fn test_divide_by_0() {
assert_eq!(divide(81, 0), Err(DivisionError::DivideByZero));
}
#[test]
fn test_divide_0_by_something() {
assert_eq!(divide(0, 81), Ok(0));
}
// Iterator exercises using your `divide` function
/*
#[test]
fn result_with_list() {
let numbers = vec![27, 297, 38502, 81];
let division_results = numbers.into_iter().map(|n| divide(n, 27));
let x //... Fill in here!
assert_eq!(format!("{:?}", x), "Ok([1, 11, 1426, 3])");
}
#[test]
fn list_of_results() {
let numbers = vec![27, 297, 38502, 81];
let division_results = numbers.into_iter().map(|n| divide(n, 27));
let x //... Fill in here!
assert_eq!(format!("{:?}", x), "[Ok(1), Ok(11), Ok(1426), Ok(3)]");
}
*/
}
// Minor hint: In each of the two cases in the match in main, you can create x with either
// a 'turbofish' or by hinting the type of x to the compiler. You may try both.
// Major hint: Have a look at the Iter trait and at the explanation of its collect function.
// Especially the part about Result is interesting.

View file

@ -0,0 +1,24 @@
// iterators1.rs
//
// Make me compile by filling in the `???`s
//
// When performing operations on elements within a collection, iterators are essential.
// This module helps you get familiar with the structure of using an iterator and
// how to go through elements within an iterable collection.
//
// Execute `rustlings hint iterators1` for hints :D
// I AM NOT DONE
fn main () {
let my_fav_fruits = vec!["banana", "custard apple", "avocado", "peach", "raspberry"];
let mut my_iterable_fav_fruits = ???; // TODO: Step 1
assert_eq!(my_iterable_fav_fruits.next(), Some(&"banana"));
assert_eq!(my_iterable_fav_fruits.next(), ???); // TODO: Step 2
assert_eq!(my_iterable_fav_fruits.next(), Some(&"avocado"));
assert_eq!(my_iterable_fav_fruits.next(), ???); // TODO: Step 2.1
assert_eq!(my_iterable_fav_fruits.next(), Some(&"raspberry"));
assert_eq!(my_iterable_fav_fruits.next(), ???); // TODO: Step 3
}

View file

@ -0,0 +1,60 @@
// iterators2.rs
// In this exercise, you'll learn some of the unique advantages that iterators
// can offer. Follow the steps to complete the exercise.
// As always, there are hints if you execute `rustlings hint iterators2`!
// I AM NOT DONE
// Step 1.
// Complete the `capitalize_first` function.
// "hello" -> "Hello"
pub fn capitalize_first(input: &str) -> String {
let mut c = input.chars();
match c.next() {
None => String::new(),
Some(first) => ???,
}
}
// Step 2.
// Apply the `capitalize_first` function to a slice of string slices.
// Return a vector of strings.
// ["hello", "world"] -> ["Hello", "World"]
pub fn capitalize_words_vector(words: &[&str]) -> Vec<String> {
vec![]
}
// Step 3.
// Apply the `capitalize_first` function again to a slice of string slices.
// Return a single string.
// ["hello", " ", "world"] -> "Hello World"
pub fn capitalize_words_string(words: &[&str]) -> String {
String::new()
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_success() {
assert_eq!(capitalize_first("hello"), "Hello");
}
#[test]
fn test_empty() {
assert_eq!(capitalize_first(""), "");
}
#[test]
fn test_iterate_string_vec() {
let words = vec!["hello", "world"];
assert_eq!(capitalize_words_vector(&words), ["Hello", "World"]);
}
#[test]
fn test_iterate_into_string() {
let words = vec!["hello", " ", "world"];
assert_eq!(capitalize_words_string(&words), "Hello World");
}
}

View file

@ -0,0 +1,83 @@
// iterators3.rs
// This is a bigger exercise than most of the others! You can do it!
// Here is your mission, should you choose to accept it:
// 1. Complete the divide function to get the first four tests to pass.
// 2. Get the remaining tests to pass by completing the result_with_list and
// list_of_results functions.
// Execute `rustlings hint iterators3` to get some hints!
// I AM NOT DONE
#[derive(Debug, PartialEq, Eq)]
pub enum DivisionError {
NotDivisible(NotDivisibleError),
DivideByZero,
}
#[derive(Debug, PartialEq, Eq)]
pub struct NotDivisibleError {
dividend: i32,
divisor: i32,
}
// Calculate `a` divided by `b` if `a` is evenly divisible by `b`.
// Otherwise, return a suitable error.
pub fn divide(a: i32, b: i32) -> Result<i32, DivisionError> {}
// Complete the function and return a value of the correct type so the test passes.
// Desired output: Ok([1, 11, 1426, 3])
fn result_with_list() -> () {
let numbers = vec![27, 297, 38502, 81];
let division_results = numbers.into_iter().map(|n| divide(n, 27));
}
// Complete the function and return a value of the correct type so the test passes.
// Desired output: [Ok(1), Ok(11), Ok(1426), Ok(3)]
fn list_of_results() -> () {
let numbers = vec![27, 297, 38502, 81];
let division_results = numbers.into_iter().map(|n| divide(n, 27));
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_success() {
assert_eq!(divide(81, 9), Ok(9));
}
#[test]
fn test_not_divisible() {
assert_eq!(
divide(81, 6),
Err(DivisionError::NotDivisible(NotDivisibleError {
dividend: 81,
divisor: 6
}))
);
}
#[test]
fn test_divide_by_0() {
assert_eq!(divide(81, 0), Err(DivisionError::DivideByZero));
}
#[test]
fn test_divide_0_by_something() {
assert_eq!(divide(0, 81), Ok(0));
}
#[test]
fn test_result_with_list() {
assert_eq!(format!("{:?}", result_with_list()), "Ok([1, 11, 1426, 3])");
}
#[test]
fn test_list_of_results() {
assert_eq!(
format!("{:?}", list_of_results()),
"[Ok(1), Ok(11), Ok(1426), Ok(3)]"
);
}
}

39
exercises/standard_library_types/iterators4.rs Executable file → Normal file
View file

@ -1,15 +1,17 @@
// iterators4.rs
// I AM NOT DONE
pub fn factorial(num: u64) -> u64 {
// Complete this function to return factorial of num
// Complete this function to return the factorial of num
// Do not use:
// - return
// For extra fun don't use:
// Try not to use:
// - imperative style loops (for, while)
// - additional variables
// For the most fun don't use:
// For an extra challenge, don't use:
// - recursion
// Scroll down for hints.
// Execute `rustlings hint iterators4` for hints.
}
#[cfg(test)]
@ -30,32 +32,3 @@ mod tests {
assert_eq!(24, factorial(4));
}
}
// In an imperative language you might write a for loop to iterate through
// multiply the values into a mutable variable. Or you might write code more
// functionally with recursion and a match clause. But you can also use ranges
// and iterators to solve this in rust.

View file

@ -0,0 +1,124 @@
// iterators5.rs
// Let's define a simple model to track Rustlings exercise progress. Progress
// will be modelled using a hash map. The name of the exercise is the key and
// the progress is the value. Two counting functions were created to count the
// number of exercises with a given progress. These counting functions use
// imperative style for loops. Recreate this counting functionality using
// iterators. Only the two iterator methods (count_iterator and
// count_collection_iterator) need to be modified.
// Execute `rustlings hint
// iterators5` for hints.
//
// Make the code compile and the tests pass.
// I AM NOT DONE
use std::collections::HashMap;
#[derive(PartialEq, Eq)]
enum Progress {
None,
Some,
Complete,
}
fn count_for(map: &HashMap<String, Progress>, value: Progress) -> usize {
let mut count = 0;
for val in map.values() {
if val == &value {
count += 1;
}
}
count
}
fn count_iterator(map: &HashMap<String, Progress>, value: Progress) -> usize {
// map is a hashmap with String keys and Progress values.
// map = { "variables1": Complete, "from_str": None, ... }
}
fn count_collection_for(collection: &[HashMap<String, Progress>], value: Progress) -> usize {
let mut count = 0;
for map in collection {
for val in map.values() {
if val == &value {
count += 1;
}
}
}
count
}
fn count_collection_iterator(collection: &[HashMap<String, Progress>], value: Progress) -> usize {
// collection is a slice of hashmaps.
// collection = [{ "variables1": Complete, "from_str": None, ... },
// { "variables2": Complete, ... }, ... ]
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn count_complete() {
let map = get_map();
assert_eq!(3, count_iterator(&map, Progress::Complete));
}
#[test]
fn count_equals_for() {
let map = get_map();
assert_eq!(
count_for(&map, Progress::Complete),
count_iterator(&map, Progress::Complete)
);
}
#[test]
fn count_collection_complete() {
let collection = get_vec_map();
assert_eq!(
6,
count_collection_iterator(&collection, Progress::Complete)
);
}
#[test]
fn count_collection_equals_for() {
let collection = get_vec_map();
assert_eq!(
count_collection_for(&collection, Progress::Complete),
count_collection_iterator(&collection, Progress::Complete)
);
}
fn get_map() -> HashMap<String, Progress> {
use Progress::*;
let mut map = HashMap::new();
map.insert(String::from("variables1"), Complete);
map.insert(String::from("functions1"), Complete);
map.insert(String::from("hashmap1"), Complete);
map.insert(String::from("arc1"), Some);
map.insert(String::from("as_ref_mut"), None);
map.insert(String::from("from_str"), None);
map
}
fn get_vec_map() -> Vec<HashMap<String, Progress>> {
use Progress::*;
let map = get_map();
let mut other = HashMap::new();
other.insert(String::from("variables2"), Complete);
other.insert(String::from("functions2"), Complete);
other.insert(String::from("if1"), Complete);
other.insert(String::from("from_into"), None);
other.insert(String::from("try_from_into"), None);
vec![map, other]
}
}

View file

@ -1,9 +1,9 @@
### Strings
# Strings
Rust has two string types, a string slice (`&str`) and an owned string (`String`).
We're not going to dictate when you should use which one, but we'll show you how
to identify and create them, as well as use them.
#### Book Sections
## Further information
- [Strings](https://doc.rust-lang.org/stable/book/ch08-02-strings.html)
- [Strings](https://doc.rust-lang.org/book/ch08-02-strings.html)

42
exercises/strings/strings1.rs Executable file → Normal file
View file

@ -1,5 +1,6 @@
// strings1.rs
// Make me compile without changing the function signature! Scroll down for hints :)
// Make me compile without changing the function signature!
// Execute `rustlings hint strings1` for hints ;)
fn main() {
let answer = current_favorite_color();
@ -7,40 +8,7 @@ fn main() {
}
fn current_favorite_color() -> String {
"blue"
// .to_string uses fmt trait
// .to_owned works too
"blue".to_owned()
}
// The `current_favorite_color` function is currently returning a string slice with the `'static`
// lifetime. We know this because the data of the string lives in our code itself -- it doesn't
// come from a file or user input or another program -- so it will live as long as our program
// lives. But it is still a string slice. There's one way to create a `String` by converting a
// string slice covered in the Strings chapter of the book, and another way that uses the `From`
// trait.

34
exercises/strings/strings2.rs Executable file → Normal file
View file

@ -1,5 +1,6 @@
// strings2.rs
// Make me compile without changing the function signature! Scroll down for hints :)
// Make me compile without changing the function signature!
// Execute `rustlings hint strings2` for hints :)
fn main() {
let word = String::from("green"); // Try not changing this line :)
@ -10,35 +11,6 @@ fn main() {
}
}
fn is_a_color_word(attempt: &str) -> bool {
fn is_a_color_word(attempt: String) -> bool {
attempt == "green" || attempt == "blue" || attempt == "red"
}
// Yes, it would be really easy to fix this by just changing the value bound to `word` to be a
// string slice instead of a `String`, wouldn't it?? There is a way to add one character to line
// 6, though, that will coerce the `String` into a string slice.

View file

@ -0,0 +1,8 @@
# Structs
Rust has three struct types: a classic C struct, a tuple struct, and a unit struct.
## Further information
- [Structures](https://doc.rust-lang.org/book/ch05-01-defining-structs.html)
- [Method Syntax](https://doc.rust-lang.org/book/ch05-03-method-syntax.html)

View file

@ -0,0 +1,46 @@
// structs1.rs
// Address all the TODOs to make the tests pass!
struct ColorClassicStruct {
name: String,
hex: String
}
struct ColorTupleStruct(String, String);
#[derive(Debug)]
struct UnitStruct;
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn classic_c_structs() {
// TODO: Instantiate a classic c struct!
let green = ColorClassicStruct {
name: String::from("green"),
hex: String::from("#00FF00")
};
assert_eq!(green.name, "green");
assert_eq!(green.hex, "#00FF00");
}
#[test]
fn tuple_structs() {
// TODO: Instantiate a tuple struct!
let green = ColorTupleStruct("green".to_string(),"#00FF00".to_string());
assert_eq!(green.0, "green");
assert_eq!(green.1, "#00FF00");
}
#[test]
fn unit_structs() {
// TODO: Instantiate a unit struct!
let unit_struct = UnitStruct;
let message = format!("{:?}s are fun!", unit_struct);
assert_eq!(message, "UnitStructs are fun!");
}
}

View file

@ -0,0 +1,52 @@
// structs2.rs
// Address all the TODOs to make the tests pass!
#[derive(Debug)]
struct Order {
name: String,
year: u32,
made_by_phone: bool,
made_by_mobile: bool,
made_by_email: bool,
item_number: u32,
count: u32,
}
fn create_order_template() -> Order {
Order {
name: String::from("Bob"),
year: 2019,
made_by_phone: false,
made_by_mobile: false,
made_by_email: true,
item_number: 123,
count: 0,
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn your_order() {
let order_template = create_order_template();
// TODO: Create your own order using the update syntax and template above!
let your_order = Order {
name: String::from("Hacker in Rust"),
year: 2019,
made_by_phone: false,
made_by_mobile: false,
made_by_email: true,
item_number: 123,
count: 1,
};
assert_eq!(your_order.name, "Hacker in Rust");
assert_eq!(your_order.year, order_template.year);
assert_eq!(your_order.made_by_phone, order_template.made_by_phone);
assert_eq!(your_order.made_by_mobile, order_template.made_by_mobile);
assert_eq!(your_order.made_by_email, order_template.made_by_email);
assert_eq!(your_order.item_number, order_template.item_number);
assert_eq!(your_order.count, 1);
}
}

View file

@ -0,0 +1,89 @@
// structs3.rs
// Structs contain data, but can also have logic. In this exercise we have
// defined the Package struct and we want to test some logic attached to it.
// Make the code compile and the tests pass!
// If you have issues execute `rustlings hint structs3`
#[derive(Debug)]
struct Package {
sender_country: String,
recipient_country: String,
weight_in_grams: i32,
}
impl Package {
fn new(sender_country: String, recipient_country: String, weight_in_grams: i32) -> Package {
if weight_in_grams <= 0 {
panic!("Weight is in negative value.");
} else {
return Package {
sender_country,
recipient_country,
weight_in_grams,
};
}
}
fn is_international(&self) -> bool {
if self.sender_country != self.recipient_country {
true
} else {
false
}
}
fn get_fees(&self, cents_per_gram: i32) -> i32 {
if cents_per_gram <= 0 {
panic!("We don't pay people, do we?");
} else {
cents_per_gram * self.weight_in_grams
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
#[should_panic]
fn fail_creating_weightless_package() {
let sender_country = String::from("Spain");
let recipient_country = String::from("Austria");
Package::new(sender_country, recipient_country, -2210);
}
#[test]
fn create_international_package() {
let sender_country = String::from("Spain");
let recipient_country = String::from("Russia");
let package = Package::new(sender_country, recipient_country, 1200);
assert!(package.is_international());
}
#[test]
fn create_local_package() {
let sender_country = String::from("Canada");
let recipient_country = sender_country.clone();
let package = Package::new(sender_country, recipient_country, 1200);
assert!(!package.is_international());
}
#[test]
fn calculate_transport_fees() {
let sender_country = String::from("Spain");
let recipient_country = String::from("Spain");
let cents_per_gram = 3;
let package = Package::new(sender_country, recipient_country, 1500);
assert_eq!(package.get_fees(cents_per_gram), 4500);
}
}

View file

@ -1,21 +0,0 @@
// test1.rs
// This is a test for the following sections:
// - Variables
// - Functions
// Mary is buying apples. One apple usually costs 2 dollars, but if you buy
// more than 40 at once, each apple only costs 1! Write a function that calculates
// the price of an order of apples given the order amount. No hints this time!
// Put your function here!
// fn ..... {
// Don't modify this function!
#[test]
fn verify_test() {
let price1 = calculateprice(55);
let price2 = calculateprice(40);
assert_eq!(price1, 55);
assert_eq!(price2, 80);
}

View file

@ -1,24 +0,0 @@
// strings3.rs
// This is a test for the following sections:
// - Strings
// Ok, here are a bunch of values-- some are `Strings`, some are `&strs`. Your
// task is to call one of these two functions on each value depending on what
// you think each value is. That is, add either `string_slice` or `string`
// before the parentheses on each line. If you're right, it will compile!
fn string_slice(arg: &str) { println!("{}", arg); }
fn string(arg: String) { println!("{}", arg); }
fn main() {
("blue");
("red".to_string());
(String::from("hi"));
("rust is fun!".to_owned());
("nice weather".into());
(format!("Interpolation {}", "Station"));
(&String::from("abc")[0..1]);
(" hello there ".trim());
("Happy Monday!".to_string().replace("Mon", "Tues"));
("mY sHiFt KeY iS sTiCkY".to_lowercase());
}

View file

@ -1,12 +0,0 @@
// test4.rs
// This test covers the sections:
// - Modules
// - Macros
// Write a macro that passes the test! No hints this time, you can do it!
fn main() {
if my_macro!("world!") != "Hello world!" {
panic!("Oh no! Wrong output!");
}
}

View file

@ -1,7 +1,7 @@
### Tests
# Tests
Going out of order from the book to cover tests -- many of the following exercises will ask you to make tests pass!
#### Book Sections
## Further information
- [Writing Tests](https://doc.rust-lang.org/stable/book/ch11-01-writing-tests.html)
- [Writing Tests](https://doc.rust-lang.org/book/ch11-01-writing-tests.html)

40
exercises/tests/tests1.rs Executable file → Normal file
View file

@ -1,10 +1,12 @@
// tests1.rs
// Tests are important to ensure that your code does what you think it should do.
// Tests can be run on this file with the following command:
// rustlings run --test exercises/tests/tests1.rs
// rustlings run tests1
// This test has a problem with it -- make the test compile! Make the test
// pass! Make the test fail! Scroll down for hints :)
// pass! Make the test fail! Execute `rustlings hint tests1` for hints :)
// I AM NOT DONE
#[cfg(test)]
mod tests {
@ -13,37 +15,3 @@ mod tests {
assert!();
}
}
// You don't even need to write any code to test -- you can just test values and run that, even
// though you wouldn't do that in real life :) `assert!` is a macro that needs an argument.
// Depending on the value of the argument, `assert!` will do nothing (in which case the test will
// pass) or `assert!` will panic (in which case the test will fail). So try giving different values
// to `assert!` and see which ones compile, which ones pass, and which ones fail :)

Some files were not shown because too many files have changed in this diff Show more