1
0
mirror of https://github.com/rust-lang/rustlings.git synced 2025-12-26 00:11:49 +02:00

Compare commits

...

138 Commits
5.0.0 ... 5.2.1

Author SHA1 Message Date
mokou
c923e7af73 chore: release 5.2.1 2022-09-06 12:22:17 +02:00
liv
c838d446ad Merge pull request #1191 from rust-lang/all-contributors/add-memark
docs: add memark as a contributor for content
2022-09-06 12:17:16 +02:00
allcontributors[bot]
50323a3977 docs: update .all-contributorsrc [skip ci] 2022-09-06 10:17:08 +00:00
allcontributors[bot]
7b5ef323c5 docs: update AUTHORS.md [skip ci] 2022-09-06 10:17:07 +00:00
liv
199150fda2 Merge pull request #1171 from memark/patch-1
Add quotes for readability of output
2022-09-06 12:16:54 +02:00
liv
c1b5a0511f Merge pull request #1190 from rust-lang/all-contributors/add-miguelraz
docs: add miguelraz as a contributor for content
2022-09-06 12:14:13 +02:00
allcontributors[bot]
742200d14b docs: update .all-contributorsrc [skip ci] 2022-09-06 10:14:06 +00:00
allcontributors[bot]
900d58d054 docs: update AUTHORS.md [skip ci] 2022-09-06 10:14:05 +00:00
liv
6af86bbf22 Merge pull request #1186 from miguelraz/patch-1
typo fix
2022-09-06 12:13:51 +02:00
liv
4c1070faab Merge pull request #1189 from rust-lang/all-contributors/add-rzrymiak
docs: add rzrymiak as a contributor for content
2022-09-06 12:13:34 +02:00
allcontributors[bot]
f437f8e9ea docs: update .all-contributorsrc [skip ci] 2022-09-06 10:13:27 +00:00
allcontributors[bot]
c9c743967f docs: update AUTHORS.md [skip ci] 2022-09-06 10:13:26 +00:00
liv
88c9a23884 Merge pull request #1085 from rzrymiak/main
Update README.md
2022-09-06 12:13:09 +02:00
liv
1d5700e58a fix(quiz1): add fourth assert 2022-09-06 12:10:53 +02:00
liv
96552e07c2 fix(quiz1): correct explanation once again 2022-09-06 12:09:43 +02:00
Miguel Raz Guzmán Macedo
c97e659d78 typox fix 2022-09-05 10:18:45 -05:00
Magnus Markling
291da61fda Add quotes 2022-08-28 15:12:15 +02:00
Magnus Markling
94bdb708fe Add quotes 2022-08-28 15:10:29 +02:00
mokou
3309a01b5e chore: release 5.2.0 2022-08-27 19:48:15 +01:00
liv
5a03e46d69 Merge pull request #1166 from rust-lang/all-contributors/add-Kodylow
docs: add Kodylow as a contributor for content
2022-08-25 12:12:23 +02:00
allcontributors[bot]
bf95a34553 docs: update .all-contributorsrc [skip ci] 2022-08-25 10:12:15 +00:00
allcontributors[bot]
33e501981a docs: update AUTHORS.md [skip ci] 2022-08-25 10:12:14 +00:00
liv
4ee9a0f6b9 Merge pull request #1164 from Kodylow/quiz1-typo-fix
Fix Quiz 1 >= Typo
2022-08-25 12:11:49 +02:00
Kody Low
d6e26bb350 2nd assert is for greater than or equal to, not "more than" like it says in the instructions 2022-08-24 08:33:17 -07:00
liv
f6a37e28ba Merge pull request #1163 from rust-lang/all-contributors/add-GabrielBianconi
docs: add GabrielBianconi as a contributor for content
2022-08-24 11:16:05 +02:00
liv
a2f66e6a67 Merge pull request #1161 from GabrielBianconi/patch-1
Fix typo in `threads3` hint
2022-08-24 11:15:52 +02:00
allcontributors[bot]
b92e7b968f docs: update .all-contributorsrc [skip ci] 2022-08-24 09:15:52 +00:00
allcontributors[bot]
6c2630afcf docs: update AUTHORS.md [skip ci] 2022-08-24 09:15:51 +00:00
Gabriel Bianconi
86506fa5fd Fix typo in threads3 hint 2022-08-22 23:47:23 -04:00
liv
96098d228a Merge pull request #1151 from magnusrodseth/1031-reset-exercise
Add reset command for a given filename
2022-08-18 14:07:15 +02:00
magnusrodseth
d59dde320b chore: Add suggested changes 2022-08-18 12:47:26 +02:00
liv
fb7d3bf35d Merge pull request #1155 from rust-lang/all-contributors/add-rubiesonthesky
docs: add rubiesonthesky as a contributor for content
2022-08-18 11:54:39 +02:00
allcontributors[bot]
50272a58e2 docs: update .all-contributorsrc [skip ci] 2022-08-18 09:54:30 +00:00
allcontributors[bot]
93f60d3f8d docs: update AUTHORS.md [skip ci] 2022-08-18 09:54:29 +00:00
liv
97bf2469b6 Merge pull request #1154 from rust-lang/all-contributors/add-magnusrodseth
docs: add magnusrodseth as a contributor for content
2022-08-18 11:54:06 +02:00
allcontributors[bot]
2088dfbaf6 docs: update .all-contributorsrc [skip ci] 2022-08-18 09:53:55 +00:00
allcontributors[bot]
e889c5bb60 docs: update AUTHORS.md [skip ci] 2022-08-18 09:53:54 +00:00
liv
44d609816b Merge pull request #1150 from magnusrodseth/1109-options2-test
`options2`: Convert the main function into tests
2022-08-18 11:53:16 +02:00
magnusrodseth
99ea2cbba7 chore: make options2 not compile deliberately 2022-08-17 16:53:41 +02:00
magnusrodseth
0aff5340b5 test: Add integration tests 2022-08-17 16:43:48 +02:00
magnusrodseth
6f44cb1dd2 feat: Add reset command, given a filename 2022-08-17 16:31:53 +02:00
magnusrodseth
52a29aa84b test: Convert main function to working tests 2022-08-17 12:50:34 +02:00
mokou
d0c7b06eff chore: release 5.1.1 2022-08-17 10:43:50 +02:00
liv
5f9dd129ea Merge pull request #1149 from rust-lang/all-contributors/add-vostok92
docs: add vostok92 as a contributor for content
2022-08-17 10:41:58 +02:00
allcontributors[bot]
34392662a6 docs: update .all-contributorsrc [skip ci] 2022-08-17 08:41:50 +00:00
allcontributors[bot]
3c1fe226f0 docs: update AUTHORS.md [skip ci] 2022-08-17 08:41:49 +00:00
liv
3ac002934d Merge pull request #1148 from vostok92/main
fix(options1): wrong assertions
2022-08-17 10:41:34 +02:00
vostok92
4455c22b9a Update options1.rs
Fix assertions
2022-08-17 13:51:17 +09:00
mokou
714a8075cc chore: bump version 2022-08-16 09:54:25 +02:00
mokou
0a9d34a25a doc: update changelog 2022-08-16 09:53:40 +02:00
mokou
bb6b9e1704 doc: add zulip link 2022-08-16 09:41:41 +02:00
liv
8a4ed70762 Merge pull request #1069 from exdx/rc-exercise
feat: add rc1.rs exercise
2022-08-16 09:37:39 +02:00
liv
1c3b003c7c Merge branch 'main' into rc-exercise 2022-08-16 09:37:34 +02:00
liv
25ab52b8e7 Merge pull request #1103 from exdx/feat/cow
feat: add cow1.rs exercise
2022-08-16 09:35:53 +02:00
liv
cd0ee50dd7 Merge pull request #1146 from rust-lang/all-contributors/add-nico-vromans
docs: add nico-vromans as a contributor for content
2022-08-16 09:32:57 +02:00
allcontributors[bot]
2f2f141564 docs: update .all-contributorsrc [skip ci] 2022-08-16 07:32:32 +00:00
allcontributors[bot]
4400ce2892 docs: update AUTHORS.md [skip ci] 2022-08-16 07:32:31 +00:00
liv
cc1b22d45f Merge pull request #1144 from nico-vromans/patch-1
Update options1.rs
2022-08-16 09:32:18 +02:00
Nico Vromans
e8122daa87 Update options1.rs
Added extra test for before 10PM and updated the test for at 10PM (when it's 10PM there should already not be any ice cream left, as per the description). Also fixed the `raw_value` test, as it is later than 10PM, so there should be no more ice cream left.
2022-08-15 10:05:50 +02:00
liv
8dfffe8aa2 Merge pull request #1141 from rust-lang/all-contributors/add-markusboehme
docs: add markusboehme as a contributor for code
2022-08-12 10:25:27 +02:00
allcontributors[bot]
f107e2f31d docs: update .all-contributorsrc [skip ci] 2022-08-12 08:25:13 +00:00
allcontributors[bot]
cf813b707c docs: update AUTHORS.md [skip ci] 2022-08-12 08:25:12 +00:00
liv
2b0c73c7e4 Merge pull request #1140 from markusboehme/fix/options1/remove-unused-code
fix(options1): remove unused code
2022-08-12 10:24:58 +02:00
Markus Boehme
3c84cc1702 fix(options1): remove unused code
Since rewriting the exercise in commit 06e4fd3765 the print_number
function goes unused. Remove it.
2022-08-11 22:54:08 +02:00
liv
57377e8bf7 Merge pull request #1139 from rust-lang/all-contributors/add-brianfakhoury
docs: add brianfakhoury as a contributor for content
2022-08-11 12:38:36 +02:00
allcontributors[bot]
a16e7b918a docs: update .all-contributorsrc [skip ci] 2022-08-11 10:38:01 +00:00
allcontributors[bot]
7e1a4c0363 docs: update AUTHORS.md [skip ci] 2022-08-11 10:38:00 +00:00
liv
cfbce9d225 Merge pull request #1138 from rust-lang/all-contributors/add-johnmendel
docs: add johnmendel as a contributor for code
2022-08-11 12:31:22 +02:00
allcontributors[bot]
c1c4f86317 docs: update .all-contributorsrc [skip ci] 2022-08-11 10:30:25 +00:00
allcontributors[bot]
dcf4efe628 docs: update AUTHORS.md [skip ci] 2022-08-11 10:30:24 +00:00
liv
26b347a8bd Merge pull request #1131 from johnmendel/main
fix(traits5): make exercise prefer trait-based solution
2022-08-11 12:30:12 +02:00
liv
3c85fc4d39 Merge pull request #1136 from rust-lang/all-contributors/add-Mouwrice
docs: add Mouwrice as a contributor for content
2022-08-11 12:29:35 +02:00
liv
a7ca40d8a3 Merge pull request #1132 from brianfakhoury/patch-1
Fix minor spelling
2022-08-11 12:29:16 +02:00
allcontributors[bot]
8d9df94b6c docs: update .all-contributorsrc [skip ci] 2022-08-11 10:27:28 +00:00
allcontributors[bot]
bf84fe029f docs: update AUTHORS.md [skip ci] 2022-08-11 10:27:27 +00:00
liv
ca96e32ff7 Merge pull request #1133 from Mouwrice/fix/macro-readme-book-link
fix(macros-readme): update the book link to the more recent version of the book
2022-08-11 12:27:12 +02:00
Mouwrice
ef70ad907f fix(macros-readme): update the book link to the more recent version of the book 2022-08-09 20:27:27 +02:00
Brian Fakhoury
f25f77e915 Fix minor spelling 2022-08-08 15:39:35 -04:00
John Mendelewski III
a0a06232ce fix(traits5): make exercise prefer trait-based solution
closes #1088
2022-08-07 14:51:16 -04:00
liv
300cdc27dd Merge pull request #1123 from rust-lang/all-contributors/add-clairew
docs: add clairew as a contributor for content
2022-08-03 17:36:14 +02:00
allcontributors[bot]
7a7281764c docs: update .all-contributorsrc [skip ci] 2022-08-03 15:36:08 +00:00
allcontributors[bot]
d27c12e35d docs: update AUTHORS.md [skip ci] 2022-08-03 15:36:07 +00:00
liv
cbf9016187 Merge pull request #1110 from clairew/fix/info-toml-typo
fix: remove extra " typo in info.toml
2022-08-03 17:35:51 +02:00
liv
6ac42c5141 Merge pull request #1122 from rust-lang/all-contributors/add-tvkn
docs: add tvkn as a contributor for content
2022-08-03 17:35:08 +02:00
allcontributors[bot]
6289238d1d docs: update .all-contributorsrc [skip ci] 2022-08-03 15:35:00 +00:00
allcontributors[bot]
e3b65186fd docs: update AUTHORS.md [skip ci] 2022-08-03 15:34:59 +00:00
liv
affc815447 Merge pull request #1112 from tvkn/feat/options1/update-expected-result
feat(options1): update expected result
2022-08-03 17:34:43 +02:00
mokou
af301a2efe feat(errors5): add simpler explanation for box dyn 2022-08-03 17:31:42 +02:00
liv
977a167335 Merge pull request #1121 from rust-lang/all-contributors/add-Lioness100
docs: add Lioness100 as a contributor for content
2022-08-03 17:13:28 +02:00
allcontributors[bot]
08f42761f9 docs: update .all-contributorsrc [skip ci] 2022-08-03 15:13:19 +00:00
allcontributors[bot]
a04d62372f docs: update AUTHORS.md [skip ci] 2022-08-03 15:13:18 +00:00
liv
5a8f2b62e3 Merge pull request #1117 from Lioness100/refactor/todo
refactor(box1): prefer todo! over unimplemented!
2022-08-03 17:12:58 +02:00
Lioness100
c5ecc37a9a refactor(box1): prefer todo! over unimplemented! 2022-07-30 10:50:07 -04:00
Tristan Nicholls
a56f648cce feat(options1): update expected result
Expected result is updated to better showcase the difference between
- a valid result with no ice-creams `Some(0)`, and
- an invalid result `None`.
2022-07-26 21:01:09 +02:00
Claire Wang
a3a5fbeddf fix: remove extra " typo in info.toml 2022-07-25 19:00:35 -07:00
liv
3963559810 Merge pull request #1106 from rust-lang/all-contributors/add-thatlittleboy
docs: add thatlittleboy as a contributor for content
2022-07-24 23:26:20 +02:00
allcontributors[bot]
4bee3399f8 docs: update .all-contributorsrc [skip ci] 2022-07-24 21:26:13 +00:00
allcontributors[bot]
32687cc66e docs: update AUTHORS.md [skip ci] 2022-07-24 21:26:12 +00:00
liv
d21a8e63c1 Merge pull request #1102 from thatlittleboy/fix/hints-typos
Fix/hints typos
2022-07-24 23:25:58 +02:00
Denton24646
72e21a2a6c feat: add cow1.rs exercise 2022-07-23 17:59:53 -04:00
Jeremy Goh
301bc52857 fix: lineno typo 2022-07-24 00:37:40 +08:00
Jeremy Goh
f88c7d1e8c fix: reference to variables4 2022-07-24 00:36:27 +08:00
liv
3a327096c6 Merge pull request #1101 from rust-lang/all-contributors/add-saikatdas0790
docs: add saikatdas0790 as a contributor for content
2022-07-23 17:41:10 +02:00
allcontributors[bot]
7a6079b46a docs: update .all-contributorsrc [skip ci] 2022-07-23 15:41:03 +00:00
allcontributors[bot]
c1fc77e50f docs: update AUTHORS.md [skip ci] 2022-07-23 15:41:02 +00:00
liv
cbca27dffe Merge pull request #1099 from saikatdas0790/patch-1
Fix manual installation with install to the current directory
2022-07-23 17:40:43 +02:00
liv
5cb40b2c95 Merge pull request #1094 from greg-el/main
fix(run): correct "PAS" in `integration_tests.rs`
2022-07-23 17:38:27 +02:00
liv
e0fb7e72bb Merge pull request #1100 from rust-lang/all-contributors/add-EdwinChang24
docs: add EdwinChang24 as a contributor for content
2022-07-23 17:37:13 +02:00
allcontributors[bot]
e858fd94fb docs: update .all-contributorsrc [skip ci] 2022-07-23 15:37:06 +00:00
allcontributors[bot]
56c05f6232 docs: update AUTHORS.md [skip ci] 2022-07-23 15:37:05 +00:00
liv
2663cc8e80 Merge pull request #1092 from EdwinChang24/fix-editorconfig
fix: Fix typo in .editorconfig
2022-07-23 17:36:42 +02:00
Saikat Das
2356b5c1b6 Fix manual installation with install to the current directory 2022-07-23 15:55:30 +05:30
Greg Leonard
e9f5c9423c fix(run): correct "PAS" in integration_tests.rs 2022-07-21 23:13:22 +01:00
Edwin Chang
f34d390bba fix: Fix typo in .editorconfig 2022-07-20 18:23:31 -04:00
liv
fb7dac75a7 Merge pull request #1089 from greg-el/main
fix(traits5): fix "paramter" spelling
2022-07-20 09:09:43 +02:00
Greg Leonard
f9413b8ae1 fix(traits5): fix "paramter" spelling 2022-07-19 20:05:04 +01:00
liv
fef10b8a0f Merge pull request #1087 from rust-lang/all-contributors/add-PrettyWood
docs: add PrettyWood as a contributor for content
2022-07-19 14:40:31 +02:00
allcontributors[bot]
82c41a61b6 docs: update .all-contributorsrc [skip ci] 2022-07-19 12:40:23 +00:00
allcontributors[bot]
3b74f5dae8 docs: update AUTHORS.md [skip ci] 2022-07-19 12:40:22 +00:00
liv
316fc58b4c Merge pull request #1086 from PrettyWood/patch-2
remove small typo in hint of threads3
2022-07-19 14:40:07 +02:00
Eric Jolibois
8a4dca5fa6 remove small typo in hint of threads3 2022-07-19 11:45:34 +02:00
rzrymiak
4910bae10f Update README.md
Minor grammatical edit in README.md
2022-07-18 17:00:16 -07:00
liv
0e7de2e7a7 Merge pull request #1079 from Tostapunk/fix/lifetimes-patch1
fix: Improve hint of lifetimes2
2022-07-18 16:06:16 +02:00
Mattia Schiavon
e1d6abb4c9 Apply suggestions from code review
Co-authored-by: liv <mokou@fastmail.com>
2022-07-18 14:44:16 +02:00
Tostapunk
02d78c3e84 fix: Improve hint of lifetimes2
fixes #1071
2022-07-18 14:11:51 +02:00
liv
727fc3037c Merge pull request #1078 from rust-lang/all-contributors/add-Tostapunk
docs: add Tostapunk as a contributor for content
2022-07-18 10:48:20 +02:00
allcontributors[bot]
1aecf32748 docs: update .all-contributorsrc [skip ci] 2022-07-18 08:47:49 +00:00
allcontributors[bot]
2f113b9b06 docs: update AUTHORS.md [skip ci] 2022-07-18 08:47:49 +00:00
liv
d46a97ef97 Merge pull request #1076 from Tostapunk/main
fix(traits5.rs): wrong line number
2022-07-18 10:47:35 +02:00
Tostapunk
7035d6787c fix(traits5.rs): wrong line number 2022-07-18 00:27:57 +02:00
Denton24646
ce86d252e5 feat: add rc1.rs exercise 2022-07-16 17:39:03 -04:00
liv
8a0c6cfcfa Merge pull request #1068 from wojexe/patch-2
fix(traits4.rs): wrong line number
2022-07-16 20:48:09 +02:00
wojexe
b0e070c743 fix(traits4.rs): wrong line number
fixes #1067
2022-07-16 19:51:50 +02:00
liv
ab291a1fcd Merge pull request #1065 from rust-lang/all-contributors/add-wojexe
docs: add wojexe as a contributor for content
2022-07-16 18:27:48 +02:00
allcontributors[bot]
3bb008ebbb docs: update .all-contributorsrc [skip ci] 2022-07-16 16:27:41 +00:00
allcontributors[bot]
e8cf9b2628 docs: update AUTHORS.md [skip ci] 2022-07-16 16:27:40 +00:00
liv
179202a34a Merge pull request #1064 from wojexe/patch-1
fix: make strings3.rs comment wording more clear
2022-07-16 18:27:26 +02:00
wojexe
55900c65cb fix: make strings3.rs comment wording more clear
fixes #1063
2022-07-16 17:28:13 +02:00
25 changed files with 651 additions and 80 deletions

View File

@@ -1371,6 +1371,204 @@
"contributions": [
"content"
]
},
{
"login": "wojexe",
"name": "wojexe",
"avatar_url": "https://avatars.githubusercontent.com/u/21208490?v=4",
"profile": "https://wojexe.com",
"contributions": [
"content"
]
},
{
"login": "Tostapunk",
"name": "Mattia Schiavon",
"avatar_url": "https://avatars.githubusercontent.com/u/25140297?v=4",
"profile": "https://github.com/Tostapunk",
"contributions": [
"content"
]
},
{
"login": "PrettyWood",
"name": "Eric Jolibois",
"avatar_url": "https://avatars.githubusercontent.com/u/18406791?v=4",
"profile": "http://toucantoco.com",
"contributions": [
"content"
]
},
{
"login": "EdwinChang24",
"name": "Edwin Chang",
"avatar_url": "https://avatars.githubusercontent.com/u/88263098?v=4",
"profile": "http://edwinchang.vercel.app",
"contributions": [
"content"
]
},
{
"login": "saikatdas0790",
"name": "Saikat Das",
"avatar_url": "https://avatars.githubusercontent.com/u/7412443?v=4",
"profile": "https://saikat.dev/",
"contributions": [
"content"
]
},
{
"login": "thatlittleboy",
"name": "Jeremy Goh",
"avatar_url": "https://avatars.githubusercontent.com/u/30731072?v=4",
"profile": "https://github.com/thatlittleboy",
"contributions": [
"content"
]
},
{
"login": "Lioness100",
"name": "Lioness100",
"avatar_url": "https://avatars.githubusercontent.com/u/65814829?v=4",
"profile": "https://github.com/Lioness100",
"contributions": [
"content"
]
},
{
"login": "tvkn",
"name": "Tristan Nicholls",
"avatar_url": "https://avatars.githubusercontent.com/u/79277926?v=4",
"profile": "https://github.com/tvkn",
"contributions": [
"content"
]
},
{
"login": "clairew",
"name": "Claire",
"avatar_url": "https://avatars.githubusercontent.com/u/9344258?v=4",
"profile": "http://clairewang.net",
"contributions": [
"content"
]
},
{
"login": "Mouwrice",
"name": "Maurice Van Wassenhove",
"avatar_url": "https://avatars.githubusercontent.com/u/56763273?v=4",
"profile": "https://github.com/Mouwrice",
"contributions": [
"content"
]
},
{
"login": "johnmendel",
"name": "John Mendelewski",
"avatar_url": "https://avatars.githubusercontent.com/u/77524?v=4",
"profile": "http://jmthree.com",
"contributions": [
"code"
]
},
{
"login": "brianfakhoury",
"name": "Brian Fakhoury",
"avatar_url": "https://avatars.githubusercontent.com/u/20828724?v=4",
"profile": "http://fakhoury.xyz",
"contributions": [
"content"
]
},
{
"login": "markusboehme",
"name": "Markus Boehme",
"avatar_url": "https://avatars.githubusercontent.com/u/5074759?v=4",
"profile": "https://github.com/markusboehme",
"contributions": [
"code"
]
},
{
"login": "nico-vromans",
"name": "Nico Vromans",
"avatar_url": "https://avatars.githubusercontent.com/u/48183857?v=4",
"profile": "https://github.com/nico-vromans",
"contributions": [
"content"
]
},
{
"login": "vostok92",
"name": "vostok92",
"avatar_url": "https://avatars.githubusercontent.com/u/540339?v=4",
"profile": "https://github.com/vostok92",
"contributions": [
"content"
]
},
{
"login": "magnusrodseth",
"name": "Magnus Rødseth",
"avatar_url": "https://avatars.githubusercontent.com/u/59113973?v=4",
"profile": "http://magnusrodseth.vercel.app",
"contributions": [
"content"
]
},
{
"login": "rubiesonthesky",
"name": "rubiesonthesky",
"avatar_url": "https://avatars.githubusercontent.com/u/2591240?v=4",
"profile": "https://github.com/rubiesonthesky",
"contributions": [
"content"
]
},
{
"login": "GabrielBianconi",
"name": "Gabriel Bianconi",
"avatar_url": "https://avatars.githubusercontent.com/u/1275491?v=4",
"profile": "http://www.gabrielbianconi.com/",
"contributions": [
"content"
]
},
{
"login": "Kodylow",
"name": "Kody Low",
"avatar_url": "https://avatars.githubusercontent.com/u/74332828?v=4",
"profile": "https://github.com/Kodylow",
"contributions": [
"content"
]
},
{
"login": "rzrymiak",
"name": "rzrymiak",
"avatar_url": "https://avatars.githubusercontent.com/u/106121613?v=4",
"profile": "https://github.com/rzrymiak",
"contributions": [
"content"
]
},
{
"login": "miguelraz",
"name": "Miguel Raz Guzmán Macedo",
"avatar_url": "https://avatars.githubusercontent.com/u/13056181?v=4",
"profile": "https://github.com/miguelraz",
"contributions": [
"content"
]
},
{
"login": "memark",
"name": "Magnus Markling",
"avatar_url": "https://avatars.githubusercontent.com/u/318504?v=4",
"profile": "https://github.com/memark",
"contributions": [
"content"
]
}
],
"contributorsPerLine": 8,

View File

@@ -2,6 +2,6 @@ root = true
[*.rs]
end_of_line = lf
insert_final_newfile = true
insert_final_newline = true
indent_style = space
indent_size = 4

View File

@@ -195,6 +195,34 @@ authors.
<td align="center"><a href="https://jamesabromley.wordpress.com/"><img src="https://avatars.githubusercontent.com/u/2474334?v=4?s=100" width="100px;" alt=""/><br /><sub><b>James Bromley</b></sub></a><br /><a href="#content-jayber" title="Content">🖋</a></td>
<td align="center"><a href="https://github.com/swhiteCQC"><img src="https://avatars.githubusercontent.com/u/77438466?v=4?s=100" width="100px;" alt=""/><br /><sub><b>swhiteCQC</b></sub></a><br /><a href="#content-swhiteCQC" title="Content">🖋</a></td>
<td align="center"><a href="https://github.com/neilpate"><img src="https://avatars.githubusercontent.com/u/7802334?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Neil Pate</b></sub></a><br /><a href="#content-neilpate" title="Content">🖋</a></td>
<td align="center"><a href="https://wojexe.com"><img src="https://avatars.githubusercontent.com/u/21208490?v=4?s=100" width="100px;" alt=""/><br /><sub><b>wojexe</b></sub></a><br /><a href="#content-wojexe" title="Content">🖋</a></td>
<td align="center"><a href="https://github.com/Tostapunk"><img src="https://avatars.githubusercontent.com/u/25140297?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Mattia Schiavon</b></sub></a><br /><a href="#content-Tostapunk" title="Content">🖋</a></td>
<td align="center"><a href="http://toucantoco.com"><img src="https://avatars.githubusercontent.com/u/18406791?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Eric Jolibois</b></sub></a><br /><a href="#content-PrettyWood" title="Content">🖋</a></td>
</tr>
<tr>
<td align="center"><a href="http://edwinchang.vercel.app"><img src="https://avatars.githubusercontent.com/u/88263098?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Edwin Chang</b></sub></a><br /><a href="#content-EdwinChang24" title="Content">🖋</a></td>
<td align="center"><a href="https://saikat.dev/"><img src="https://avatars.githubusercontent.com/u/7412443?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Saikat Das</b></sub></a><br /><a href="#content-saikatdas0790" title="Content">🖋</a></td>
<td align="center"><a href="https://github.com/thatlittleboy"><img src="https://avatars.githubusercontent.com/u/30731072?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jeremy Goh</b></sub></a><br /><a href="#content-thatlittleboy" title="Content">🖋</a></td>
<td align="center"><a href="https://github.com/Lioness100"><img src="https://avatars.githubusercontent.com/u/65814829?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Lioness100</b></sub></a><br /><a href="#content-Lioness100" title="Content">🖋</a></td>
<td align="center"><a href="https://github.com/tvkn"><img src="https://avatars.githubusercontent.com/u/79277926?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Tristan Nicholls</b></sub></a><br /><a href="#content-tvkn" title="Content">🖋</a></td>
<td align="center"><a href="http://clairewang.net"><img src="https://avatars.githubusercontent.com/u/9344258?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Claire</b></sub></a><br /><a href="#content-clairew" title="Content">🖋</a></td>
<td align="center"><a href="https://github.com/Mouwrice"><img src="https://avatars.githubusercontent.com/u/56763273?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Maurice Van Wassenhove</b></sub></a><br /><a href="#content-Mouwrice" title="Content">🖋</a></td>
<td align="center"><a href="http://jmthree.com"><img src="https://avatars.githubusercontent.com/u/77524?v=4?s=100" width="100px;" alt=""/><br /><sub><b>John Mendelewski</b></sub></a><br /><a href="https://github.com/rust-lang/rustlings/commits?author=johnmendel" title="Code">💻</a></td>
</tr>
<tr>
<td align="center"><a href="http://fakhoury.xyz"><img src="https://avatars.githubusercontent.com/u/20828724?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Brian Fakhoury</b></sub></a><br /><a href="#content-brianfakhoury" title="Content">🖋</a></td>
<td align="center"><a href="https://github.com/markusboehme"><img src="https://avatars.githubusercontent.com/u/5074759?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Markus Boehme</b></sub></a><br /><a href="https://github.com/rust-lang/rustlings/commits?author=markusboehme" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/nico-vromans"><img src="https://avatars.githubusercontent.com/u/48183857?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Nico Vromans</b></sub></a><br /><a href="#content-nico-vromans" title="Content">🖋</a></td>
<td align="center"><a href="https://github.com/vostok92"><img src="https://avatars.githubusercontent.com/u/540339?v=4?s=100" width="100px;" alt=""/><br /><sub><b>vostok92</b></sub></a><br /><a href="#content-vostok92" title="Content">🖋</a></td>
<td align="center"><a href="http://magnusrodseth.vercel.app"><img src="https://avatars.githubusercontent.com/u/59113973?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Magnus Rødseth</b></sub></a><br /><a href="#content-magnusrodseth" title="Content">🖋</a></td>
<td align="center"><a href="https://github.com/rubiesonthesky"><img src="https://avatars.githubusercontent.com/u/2591240?v=4?s=100" width="100px;" alt=""/><br /><sub><b>rubiesonthesky</b></sub></a><br /><a href="#content-rubiesonthesky" title="Content">🖋</a></td>
<td align="center"><a href="http://www.gabrielbianconi.com/"><img src="https://avatars.githubusercontent.com/u/1275491?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Gabriel Bianconi</b></sub></a><br /><a href="#content-GabrielBianconi" title="Content">🖋</a></td>
<td align="center"><a href="https://github.com/Kodylow"><img src="https://avatars.githubusercontent.com/u/74332828?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Kody Low</b></sub></a><br /><a href="#content-Kodylow" title="Content">🖋</a></td>
</tr>
<tr>
<td align="center"><a href="https://github.com/rzrymiak"><img src="https://avatars.githubusercontent.com/u/106121613?v=4?s=100" width="100px;" alt=""/><br /><sub><b>rzrymiak</b></sub></a><br /><a href="#content-rzrymiak" title="Content">🖋</a></td>
<td align="center"><a href="https://github.com/miguelraz"><img src="https://avatars.githubusercontent.com/u/13056181?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Miguel Raz Guzmán Macedo</b></sub></a><br /><a href="#content-miguelraz" title="Content">🖋</a></td>
<td align="center"><a href="https://github.com/memark"><img src="https://avatars.githubusercontent.com/u/318504?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Magnus Markling</b></sub></a><br /><a href="#content-memark" title="Content">🖋</a></td>
</tr>
</table>

View File

@@ -1,3 +1,76 @@
<a name="5.2.1"></a>
## 5.2.1 (2022-09-06)
#### Fixed
- **quiz1**: Reworded the comment to actually reflect what's going on in the tests.
Also added another assert just to make sure.
- **rc1**: Fixed a typo in the hint.
- **lifetimes**: Add quotes to the `println!` output, for readability.
#### Housekeeping
- Fixed a typo in README.md
<a name="5.2.0"></a>
## 5.2.0 (2022-08-27)
#### Added
- Added a `reset` command
#### Changed
- **options2**: Convert the exercise to use tests
#### Fixed
- **threads3**: Fixed a typo
- **quiz1**: Adjusted the explanations to be consistent with
the tests
<a name="5.1.1"></a>
## 5.1.1 (2022-08-17)
#### Bug Fixes
- Fixed an incorrect assertion in options1
<a name="5.1.0"></a>
## 5.1.0 (2022-08-16)
#### Features
- Added a new `rc1` exercise.
- Added a new `cow1` exercise.
#### Bug Fixes
- **variables5**: Corrected reference to previous exercise
- **functions4**: Fixed line number reference
- **strings3**: Clarified comment wording
- **traits4, traits5**: Fixed line number reference
- **traits5**:
- Fixed typo in "parameter"
- Made exercise prefer a traits-based solution
- **lifetimes2**: Improved hint
- **threads3**: Fixed typo in hint
- **box1**: Replaced `unimplemented!` with `todo!`
- **errors5**: Provided an explanation for usage of `Box<dyn Error>`
- **quiz2**: Fixed a typo
- **macros**: Updated the macros book link
- **options1**:
- Removed unused code
- Added more granular tests
- Fixed some comment syntax shenanigans in info.toml
#### Housekeeping
- Fixed a typo in .editorconfig
- Fixed a typo in integration_tests.rs
- Clarified manual installation instructions using `cargo install --path .`
- Added a link to our Zulip in the readme file
<a name="5.0.0"></a>
## 5.0.0 (2022-07-16)

2
Cargo.lock generated
View File

@@ -459,7 +459,7 @@ checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b"
[[package]]
name = "rustlings"
version = "4.8.0"
version = "5.2.1"
dependencies = [
"argh",
"assert_cmd",

View File

@@ -1,6 +1,6 @@
[package]
name = "rustlings"
version = "5.0.0"
version = "5.2.1"
authors = ["Liv <mokou@fastmail.com>", "Carol (Nichols || Goulding) <carol.nichols@gmail.com>"]
edition = "2021"

View File

@@ -54,11 +54,11 @@ If you get a permission denied message, you might have to exclude the directory
## Manually
Basically: Clone the repository at the latest tag, run `cargo install`.
Basically: Clone the repository at the latest tag, run `cargo install --path .`.
```bash
# find out the latest version at https://github.com/rust-lang/rustlings/releases/latest (on edit 5.0.0)
git clone -b 5.0.0 --depth 1 https://github.com/rust-lang/rustlings
# find out the latest version at https://github.com/rust-lang/rustlings/releases/latest (on edit 5.2.1)
git clone -b 5.2.1 --depth 1 https://github.com/rust-lang/rustlings
cd rustlings
cargo install --force --path .
```
@@ -134,7 +134,7 @@ Once you've completed Rustlings, put your new knowledge to good use! Continue pr
## Uninstalling Rustlings
If you want to remove Rustlings from your system, there's two steps. First, you'll need to remove the exercises folder that the install script created
If you want to remove Rustlings from your system, there are two steps. First, you'll need to remove the exercises folder that the install script created
for you:
```bash
@@ -154,6 +154,10 @@ Now you should be done!
See [CONTRIBUTING.md](./CONTRIBUTING.md).
Development-focused discussion about Rustlings happens in the [**rustlings** stream](https://rust-lang.zulipchat.com/#narrow/stream/334454-rustlings)
on the [Rust Project Zulip](https://rust-lang.zulipchat.com). Feel free to start a new thread there
if you have ideas or suggestions!
## Contributors ✨
Thanks goes to the wonderful people listed in [AUTHORS.md](./AUTHORS.md) 🎉

View File

@@ -4,6 +4,8 @@
// This exercise uses some concepts that we won't get to until later in the course, like `Box` and the
// `From` trait. It's not important to understand them in detail right now, but you can read ahead if you like.
// For now, think of the `Box<dyn ...>` type as an "I want anything that does ???" type, which, given
// Rust's usual standards for runtime safety, should strike you as somewhat lenient!
// In short, this particular use case for boxes is for when you want to own a value and you care only that it is a
// type which implements a particular trait. To do so, The Box is declared as of type Box<dyn Trait> where Trait is the trait

View File

@@ -22,5 +22,5 @@ fn main() {
let string2 = "xyz";
let result = longest(string1.as_str(), string2);
println!("The longest string is {}", result);
println!("The longest string is '{}'", result);
}

View File

@@ -23,5 +23,5 @@ fn main() {
let string2 = String::from("xyz");
result = longest(string1.as_str(), string2.as_str());
}
println!("The longest string is {}", result);
println!("The longest string is '{}'", result);
}

View File

@@ -7,4 +7,4 @@ macros. Instead, we'll show you how to use and create them.
## Further information
- [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)
- [The Little Book of Rust Macros](https://veykril.github.io/tlborm/)

View File

@@ -3,17 +3,13 @@
// I AM NOT DONE
// you can modify anything EXCEPT for this function's signature
fn print_number(maybe_number: Option<u16>) {
println!("printing: {}", maybe_number.unwrap());
}
// This function returns how much icecream there is left in the fridge.
// If it's before 10PM, there's 5 pieces left. At 10PM, someone eats them
// all, so there'll be no more left :(
// TODO: Return an Option!
fn maybe_icecream(time_of_day: u16) -> Option<u16> {
// We use the 24-hour system here, so 10PM is a value of 22
// The Option output should gracefully handle cases where time_of_day > 24.
???
}
@@ -23,9 +19,11 @@ mod tests {
#[test]
fn check_icecream() {
assert_eq!(maybe_icecream(9), Some(5));
assert_eq!(maybe_icecream(10), Some(5));
assert_eq!(maybe_icecream(23), None);
assert_eq!(maybe_icecream(22), None);
assert_eq!(maybe_icecream(23), Some(0));
assert_eq!(maybe_icecream(22), Some(0));
assert_eq!(maybe_icecream(25), None);
}
#[test]

View File

@@ -3,23 +3,34 @@
// 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");
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn simple_option() {
let target = "rustlings";
let optional_target = Some(target);
// TODO: Make this an if let statement whose value is "Some" type
word = optional_target {
assert_eq!(word, target);
}
}
let mut optional_integers_vec: Vec<Option<i8>> = Vec::new();
for x in 1..10 {
optional_integers_vec.push(Some(x));
}
#[test]
fn layered_option() {
let mut range = 10;
let mut optional_integers: Vec<Option<i8>> = Vec::new();
for i in 0..(range + 1) {
optional_integers.push(Some(i));
}
// 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);
// 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.pop() {
assert_eq!(integer, range);
range -= 1;
}
}
}

View File

@@ -4,9 +4,11 @@
// - Functions
// - If
// 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 quantity bought. No hints this time!
// Mary is buying apples. The price of an apple is calculated as follows:
// - An apple costs 2 rustbucks.
// - If Mary buys more than 40 apples, each apple only costs 1 rustbuck!
// Write a function that calculates the price of an order of apples given
// the quantity bought. No hints this time!
// I AM NOT DONE
@@ -18,9 +20,11 @@
fn verify_test() {
let price1 = calculate_price_of_apples(35);
let price2 = calculate_price_of_apples(40);
let price3 = calculate_price_of_apples(65);
let price3 = calculate_price_of_apples(41);
let price4 = calculate_price_of_apples(65);
assert_eq!(70, price1);
assert_eq!(80, price2);
assert_eq!(65, price3);
assert_eq!(41, price3);
assert_eq!(65, price4);
}

View File

@@ -42,7 +42,7 @@ mod my_module {
#[cfg(test)]
mod tests {
// TODO: What to we have to import to have `transformer` in scope?
// TODO: What do we have to import to have `transformer` in scope?
use ???;
use super::Command;

View File

@@ -10,7 +10,7 @@
// 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!()`
// Step 2: create both empty and non-empty cons lists by replacing `todo!()`
//
// Note: the tests should not be changed
//
@@ -33,11 +33,11 @@ fn main() {
}
pub fn create_empty_list() -> List {
unimplemented!()
todo!()
}
pub fn create_non_empty_list() -> List {
unimplemented!()
todo!()
}
#[cfg(test)]

View File

@@ -0,0 +1,48 @@
// cow1.rs
// This exercise explores the Cow, or Clone-On-Write type.
// Cow is a clone-on-write smart pointer.
// It can enclose and provide immutable access to borrowed data, and clone the data lazily when mutation or ownership is required.
// The type is designed to work with general borrowed data via the Borrow trait.
// I AM NOT DONE
use std::borrow::Cow;
fn abs_all<'a, 'b>(input: &'a mut Cow<'b, [i32]>) -> &'a mut Cow<'b, [i32]> {
for i in 0..input.len() {
let v = input[i];
if v < 0 {
// Clones into a vector if not already owned.
input.to_mut()[i] = -v;
}
}
input
}
fn main() {
// No clone occurs because `input` doesn't need to be mutated.
let slice = [0, 1, 2];
let mut input = Cow::from(&slice[..]);
match abs_all(&mut input) {
Cow::Borrowed(_) => println!("I borrowed the slice!"),
_ => panic!("expected borrowed value"),
}
// Clone occurs because `input` needs to be mutated.
let slice = [-1, 0, 1];
let mut input = Cow::from(&slice[..]);
match abs_all(&mut input) {
Cow::Owned(_) => println!("I modified the slice and now own it!"),
_ => panic!("expected owned value"),
}
// No clone occurs because `input` is already owned.
let slice = vec![-1, 0, 1];
let mut input = Cow::from(slice);
match abs_all(&mut input) {
// TODO
Cow::Borrowed(_) => println!("I own this slice!"),
_ => panic!("expected borrowed value"),
}
}

View File

@@ -0,0 +1,98 @@
// rc1.rs
// In this exercise, we want to express the concept of multiple owners via the Rc<T> type.
// This is a model of our solar system - there is a Sun type and multiple Planets.
// The Planets take ownership of the sun, indicating that they revolve around the sun.
// Make this code compile by using the proper Rc primitives to express that the sun has multiple owners.
// I AM NOT DONE
use std::rc::Rc;
#[derive(Debug)]
struct Sun {}
#[derive(Debug)]
enum Planet {
Mercury(Rc<Sun>),
Venus(Rc<Sun>),
Earth(Rc<Sun>),
Mars(Rc<Sun>),
Jupiter(Rc<Sun>),
Saturn(Rc<Sun>),
Uranus(Rc<Sun>),
Neptune(Rc<Sun>),
}
impl Planet {
fn details(&self) {
println!("Hi from {:?}!", self)
}
}
fn main() {
let sun = Rc::new(Sun {});
println!("reference count = {}", Rc::strong_count(&sun)); // 1 reference
let mercury = Planet::Mercury(Rc::clone(&sun));
println!("reference count = {}", Rc::strong_count(&sun)); // 2 references
mercury.details();
let venus = Planet::Venus(Rc::clone(&sun));
println!("reference count = {}", Rc::strong_count(&sun)); // 3 references
venus.details();
let earth = Planet::Earth(Rc::clone(&sun));
println!("reference count = {}", Rc::strong_count(&sun)); // 4 references
earth.details();
let mars = Planet::Mars(Rc::clone(&sun));
println!("reference count = {}", Rc::strong_count(&sun)); // 5 references
mars.details();
let jupiter = Planet::Jupiter(Rc::clone(&sun));
println!("reference count = {}", Rc::strong_count(&sun)); // 6 references
jupiter.details();
// TODO
let saturn = Planet::Saturn(Rc::new(Sun {}));
println!("reference count = {}", Rc::strong_count(&sun)); // 7 references
saturn.details();
// TODO
let uranus = Planet::Uranus(Rc::new(Sun {}));
println!("reference count = {}", Rc::strong_count(&sun)); // 8 references
uranus.details();
// TODO
let neptune = Planet::Neptune(Rc::new(Sun {}));
println!("reference count = {}", Rc::strong_count(&sun)); // 9 references
neptune.details();
assert_eq!(Rc::strong_count(&sun), 9);
drop(neptune);
println!("reference count = {}", Rc::strong_count(&sun)); // 8 references
drop(uranus);
println!("reference count = {}", Rc::strong_count(&sun)); // 7 references
drop(saturn);
println!("reference count = {}", Rc::strong_count(&sun)); // 6 references
drop(jupiter);
println!("reference count = {}", Rc::strong_count(&sun)); // 5 references
drop(mars);
println!("reference count = {}", Rc::strong_count(&sun)); // 4 references
// TODO
println!("reference count = {}", Rc::strong_count(&sun)); // 3 references
// TODO
println!("reference count = {}", Rc::strong_count(&sun)); // 2 references
// TODO
println!("reference count = {}", Rc::strong_count(&sun)); // 1 reference
assert_eq!(Rc::strong_count(&sun), 1);
}

View File

@@ -4,7 +4,7 @@
// I AM NOT DONE
fn trim_me(input: &str) -> String {
// TODO: Remove whitespace from the end of a string!
// TODO: Remove whitespace from both ends of a string!
???
}

View File

@@ -1,7 +1,7 @@
// traits4.rs
//
// Your task is to replace the '??' sections so the code compiles.
// Don't change any line other than 21.
// Don't change any line other than the marked one.
// Execute `rustlings hint traits4` or use the `hint` watch subcommand for a hint.
// I AM NOT DONE
@@ -19,6 +19,7 @@ struct OtherSoftware {}
impl Licensed for SomeSoftware {}
impl Licensed for OtherSoftware {}
// YOU MAY ONLY CHANGE THE NEXT LINE
fn compare_license_types(software: ??, software_two: ??) -> bool {
software.licensing_info() == software_two.licensing_info()
}

View File

@@ -1,7 +1,7 @@
// traits5.rs
//
// Your task is to replace the '??' sections so the code compiles.
// Don't change any line other than 27.
// Don't change any line other than the marked one.
// Execute `rustlings hint traits5` or use the `hint` watch subcommand for a hint.
// I AM NOT DONE
@@ -18,15 +18,20 @@ pub trait OtherTrait {
}
}
struct SomeStruct {
name: String,
}
struct SomeStruct {}
struct OtherStruct {}
impl SomeTrait for SomeStruct {}
impl OtherTrait for SomeStruct {}
impl SomeTrait for OtherStruct {}
impl OtherTrait for OtherStruct {}
// YOU MAY ONLY CHANGE THE NEXT LINE
fn some_func(item: ??) -> bool {
item.some_function() && item.other_function()
}
fn main() {}
fn main() {
some_func(SomeStruct {});
some_func(OtherStruct {});
}

View File

@@ -63,7 +63,7 @@ name = "variables5"
path = "exercises/variables/variables5.rs"
mode = "compile"
hint = """
In variables3 we already learned how to make an immutable variable mutable
In variables4 we already learned how to make an immutable variable mutable
using a special keyword. Unfortunately this doesn't help us much in this exercise
because we want to assign a different typed value to an existing variable. Sometimes
you may also like to reuse existing variable names because you are just converting
@@ -123,8 +123,8 @@ name = "functions4"
path = "exercises/functions/functions4.rs"
mode = "compile"
hint = """
The error message points to line 14 and says it expects a type after the
`->`. This is where the function's return type should be-- take a look at
The error message points to line 17 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!
Also: Did you figure out that, technically, u32 would be the more fitting type
@@ -545,7 +545,7 @@ is the easiest, but how do you do it safely so that it doesn't panic in your fac
[[exercises]]
name = "options2"
path = "exercises/options/options2.rs"
mode = "compile"
mode = "test"
hint = """
check out:
https://doc.rust-lang.org/rust-by-example/flow_control/if_let.html
@@ -732,7 +732,7 @@ name = "traits5"
path = "exercises/traits/traits5.rs"
mode = "compile"
hint = """
To ensure a paramter implements multiple traits use the '+ syntax'. Try replacing the
To ensure a parameter implements multiple traits use the '+ syntax'. Try replacing the
'??' with 'impl <> + <>'.
See the documentation at: https://doc.rust-lang.org/book/ch10-02-traits.html#specifying-multiple-trait-bounds-with-the--syntax
@@ -746,7 +746,7 @@ path = "exercises/quiz3.rs"
mode = "test"
hint = """
To find the best solution to this challenge you're going to need to think back to your
knowledge of traits, specifically Trait Bound Syntax - you may also need this: "use std::fmt::Display;""""
knowledge of traits, specifically Trait Bound Syntax - you may also need this: `use std::fmt::Display;`."""
# TESTS
@@ -795,7 +795,10 @@ name = "lifetimes2"
path = "exercises/lifetimes/lifetimes2.rs"
mode = "compile"
hint = """
What is the compiler checking? How could you change how long an owned variable lives?"""
Remember that the generic lifetime 'a will get the concrete lifetime that is equal to the smaller of the lifetimes of x and y.
You can take at least two paths to achieve the desired result while keeping the inner block:
1. Move the string2 declaration to make it live as long as string1 (how is result declared?)
2. Move println! into the inner block"""
[[exercises]]
name = "lifetimes3"
@@ -929,6 +932,31 @@ is too much of a struggle, consider reading through all of Chapter 16 in the boo
https://doc.rust-lang.org/stable/book/ch16-00-concurrency.html
"""
[[exercises]]
name = "rc1"
path = "exercises/standard_library_types/rc1.rs"
mode = "compile"
hint = """
This is a straightforward exercise to use the Rc<T> type. Each Planet has
ownership of the Sun, and uses Rc::clone() to increment the reference count of the Sun.
After using drop() to move the Planets out of scope individually, the reference count goes down.
In the end the sun only has one reference again, to itself. See more at:
https://doc.rust-lang.org/book/ch15-04-rc.html
* Unfortunately Pluto is no longer considered a planet :(
"""
[[exercises]]
name = "cow1"
path = "exercises/standard_library_types/cow1.rs"
mode = "compile"
hint = """
Since the vector is already owned, the `Cow` type doesn't need to clone it.
Checkout https://doc.rust-lang.org/std/borrow/enum.Cow.html for documentation
on the `Cow` type.
"""
# THREADS
[[exercises]]
@@ -984,8 +1012,8 @@ hint = """
An alternate way to handle concurrency between threads is to use
a mpsc (multiple producer, single consumer) channel to communicate.
With both a sending end and a receiving end, it's possible to
send values in one thread and receieve them in another.
Multiple producers are possibile by using clone() to create a duplicate
send values in one thread and receive them in another.
Multiple producers are possible by using clone() to create a duplicate
of the original sending end.
See https://doc.rust-lang.org/book/ch16-02-message-passing.html for more info.
"""

View File

@@ -1,6 +1,6 @@
use crate::exercise::{Exercise, ExerciseList};
use crate::project::RustAnalyzerProject;
use crate::run::run;
use crate::run::{reset, run};
use crate::verify::verify;
use argh::FromArgs;
use console::Emoji;
@@ -26,7 +26,7 @@ mod run;
mod verify;
// In sync with crate version
const VERSION: &str = "5.0.0";
const VERSION: &str = "5.2.1";
#[derive(FromArgs, PartialEq, Debug)]
/// Rustlings is a collection of small exercises to get you used to writing and reading Rust code
@@ -47,6 +47,7 @@ enum Subcommands {
Verify(VerifyArgs),
Watch(WatchArgs),
Run(RunArgs),
Reset(ResetArgs),
Hint(HintArgs),
List(ListArgs),
Lsp(LspArgs),
@@ -71,6 +72,15 @@ struct RunArgs {
name: String,
}
#[derive(FromArgs, PartialEq, Debug)]
#[argh(subcommand, name = "reset")]
/// Resets a single exercise using "git stash -- <filename>"
struct ResetArgs {
#[argh(positional)]
/// the name of the exercise
name: String,
}
#[derive(FromArgs, PartialEq, Debug)]
#[argh(subcommand, name = "hint")]
/// Returns a hint for the given exercise
@@ -85,7 +95,6 @@ struct HintArgs {
/// Enable rust-analyzer for exercises
struct LspArgs {}
#[derive(FromArgs, PartialEq, Debug)]
#[argh(subcommand, name = "list")]
/// Lists the exercises available in Rustlings
@@ -164,7 +173,9 @@ fn main() {
"Pending"
};
let solve_cond = {
(e.looks_done() && subargs.solved) || (!e.looks_done() && subargs.unsolved) || (!subargs.solved && !subargs.unsolved)
(e.looks_done() && subargs.solved)
|| (!e.looks_done() && subargs.unsolved)
|| (!subargs.solved && !subargs.unsolved)
};
if solve_cond && (filter_cond || subargs.filter.is_none()) {
let line = if subargs.paths {
@@ -205,6 +216,12 @@ fn main() {
run(exercise, verbose).unwrap_or_else(|_| std::process::exit(1));
}
Subcommands::Reset(subargs) => {
let exercise = find_exercise(&subargs.name, &exercises);
reset(exercise).unwrap_or_else(|_| std::process::exit(1));
}
Subcommands::Hint(subargs) => {
let exercise = find_exercise(&subargs.name, &exercises);
@@ -212,7 +229,8 @@ fn main() {
}
Subcommands::Verify(_subargs) => {
verify(&exercises, (0, exercises.len()), verbose).unwrap_or_else(|_| std::process::exit(1));
verify(&exercises, (0, exercises.len()), verbose)
.unwrap_or_else(|_| std::process::exit(1));
}
Subcommands::Lsp(_subargs) => {
@@ -236,12 +254,18 @@ fn main() {
Subcommands::Watch(_subargs) => match watch(&exercises, verbose) {
Err(e) => {
println!("Error: Could not watch your progress. Error message was {:?}.", e);
println!(
"Error: Could not watch your progress. Error message was {:?}.",
e
);
println!("Most likely you've run out of disk space or your 'inotify limit' has been reached.");
std::process::exit(1);
}
Ok(WatchStatus::Finished) => {
println!("{emoji} All exercises completed! {emoji}", emoji = Emoji("🎉", ""));
println!(
"{emoji} All exercises completed! {emoji}",
emoji = Emoji("🎉", "")
);
println!("\n{}\n", FENISH_LINE);
}
Ok(WatchStatus::Unfinished) => {
@@ -252,8 +276,10 @@ fn main() {
}
}
fn spawn_watch_shell(failed_exercise_hint: &Arc<Mutex<Option<String>>>, should_quit: Arc<AtomicBool>) {
fn spawn_watch_shell(
failed_exercise_hint: &Arc<Mutex<Option<String>>>,
should_quit: Arc<AtomicBool>,
) {
let failed_exercise_hint = Arc::clone(failed_exercise_hint);
println!("Welcome to watch mode! You can type 'help' to get an overview of the commands you can use here.");
thread::spawn(move || loop {
@@ -290,16 +316,22 @@ fn spawn_watch_shell(failed_exercise_hint: &Arc<Mutex<Option<String>>>, should_q
fn find_exercise<'a>(name: &str, exercises: &'a [Exercise]) -> &'a Exercise {
if name.eq("next") {
exercises.iter().find(|e| !e.looks_done()).unwrap_or_else(|| {
println!("🎉 Congratulations! You have done all the exercises!");
println!("🔚 There are no more exercises to do next!");
std::process::exit(1)
})
exercises
.iter()
.find(|e| !e.looks_done())
.unwrap_or_else(|| {
println!("🎉 Congratulations! You have done all the exercises!");
println!("🔚 There are no more exercises to do next!");
std::process::exit(1)
})
} else {
exercises.iter().find(|e| e.name == name).unwrap_or_else(|| {
println!("No exercise found for '{}'!", name);
std::process::exit(1)
})
exercises
.iter()
.find(|e| e.name == name)
.unwrap_or_else(|| {
println!("No exercise found for '{}'!", name);
std::process::exit(1)
})
}
}
@@ -337,8 +369,13 @@ fn watch(exercises: &[Exercise], verbose: bool) -> notify::Result<WatchStatus> {
let filepath = b.as_path().canonicalize().unwrap();
let pending_exercises = exercises
.iter()
.find(|e| filepath.ends_with(&e.path)).into_iter()
.chain(exercises.iter().filter(|e| !e.looks_done() && !filepath.ends_with(&e.path)));
.find(|e| filepath.ends_with(&e.path))
.into_iter()
.chain(
exercises
.iter()
.filter(|e| !e.looks_done() && !filepath.ends_with(&e.path)),
);
let num_done = exercises.iter().filter(|e| e.looks_done()).count();
clear_screen();
match verify(pending_exercises, (num_done, exercises.len()), verbose) {

View File

@@ -1,3 +1,5 @@
use std::process::Command;
use crate::exercise::{Exercise, Mode};
use crate::verify::test;
use indicatif::ProgressBar;
@@ -15,6 +17,19 @@ pub fn run(exercise: &Exercise, verbose: bool) -> Result<(), ()> {
Ok(())
}
// Resets the exercise by stashing the changes.
pub fn reset(exercise: &Exercise) -> Result<(), ()> {
let command = Command::new("git")
.args(["stash", "--"])
.arg(&exercise.path)
.spawn();
match command {
Ok(_) => Ok(()),
Err(_) => Err(()),
}
}
// Invoke the rust compiler on the path of the given exercise
// and run the ensuing binary.
// This is strictly for non-test binaries, so output is displayed

View File

@@ -110,6 +110,27 @@ fn run_single_test_no_exercise() {
.code(1);
}
#[test]
fn reset_single_exercise() {
Command::cargo_bin("rustlings")
.unwrap()
.args(&["reset", "intro1"])
.assert()
.code(0);
}
#[test]
fn reset_no_exercise() {
Command::cargo_bin("rustlings")
.unwrap()
.arg("reset")
.assert()
.code(1)
.stderr(predicates::str::contains(
"positional arguments not provided",
));
}
#[test]
fn get_hint_for_single_test() {
Command::cargo_bin("rustlings")
@@ -126,7 +147,7 @@ fn all_exercises_require_confirmation() {
for exercise in glob("exercises/**/*.rs").unwrap() {
let path = exercise.unwrap();
if path.file_name().unwrap() == "mod.rs" {
continue
continue;
}
let source = {
let mut file = File::open(&path).unwrap();
@@ -176,7 +197,7 @@ fn run_single_test_success_with_output() {
.current_dir("tests/fixture/success/")
.assert()
.code(0)
.stdout(predicates::str::contains("THIS TEST TOO SHALL PAS"));
.stdout(predicates::str::contains("THIS TEST TOO SHALL PASS"));
}
#[test]
@@ -187,7 +208,7 @@ fn run_single_test_success_without_output() {
.current_dir("tests/fixture/success/")
.assert()
.code(0)
.stdout(predicates::str::contains("THIS TEST TOO SHALL PAS").not());
.stdout(predicates::str::contains("THIS TEST TOO SHALL PASS").not());
}
#[test]