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

Compare commits

...

64 Commits
4.7.0 ... 4.8.0

Author SHA1 Message Date
mokou
6588d9be22 chore: bump version 2022-07-01 16:48:34 +02:00
liv
d27f5a7d41 Merge pull request #1028 from rust-lang/all-contributors/add-jackos
docs: add jackos as a contributor for code
2022-06-17 13:01:17 +02:00
allcontributors[bot]
e48f634f34 docs: update .all-contributorsrc [skip ci] 2022-06-17 11:01:04 +00:00
allcontributors[bot]
23403546d2 docs: update AUTHORS.md [skip ci] 2022-06-17 11:01:03 +00:00
liv
294ef8d92c Merge pull request #1026 from jackos/rust-analyzer-fix
Add lsp command to fix rust-analyzer
2022-06-17 13:00:44 +02:00
Jack Clayton
be87cc9fa6 Add lsp command to fix rust-analyzer 2022-06-17 11:36:06 +08:00
diannasoreil
b19f74e8cf Merge pull request #1017 from rust-lang/dependabot/cargo/regex-1.5.5
chore(deps): bump regex from 1.5.4 to 1.5.5
2022-06-07 16:12:05 +02:00
dependabot[bot]
5130a57f8f chore(deps): bump regex from 1.5.4 to 1.5.5
Bumps [regex](https://github.com/rust-lang/regex) from 1.5.4 to 1.5.5.
- [Release notes](https://github.com/rust-lang/regex/releases)
- [Changelog](https://github.com/rust-lang/regex/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/regex/compare/1.5.4...1.5.5)

---
updated-dependencies:
- dependency-name: regex
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-06-06 21:06:16 +00:00
diannasoreil
dc6376788b Merge pull request #1007 from rust-lang/all-contributors/add-bufo24
docs: add bufo24 as a contributor for content
2022-05-23 15:57:21 +02:00
allcontributors[bot]
ffb6ecaf7e docs: update .all-contributorsrc [skip ci] 2022-05-23 13:57:00 +00:00
allcontributors[bot]
34a3c440d0 docs: update AUTHORS.md [skip ci] 2022-05-23 13:56:59 +00:00
diannasoreil
386257a06e Merge pull request #1006 from bufo24/fix-typo-in-info.toml
typo fix in hint message if2
2022-05-23 15:56:42 +02:00
Jesse van Papenrecht
0bdb5207b5 typo fix in hint message if2 2022-05-22 18:56:26 +02:00
diannasoreil
5615dd9e7d Merge pull request #1003 from rust-lang/all-contributors/add-lucasgrvarela
docs: add lucasgrvarela as a contributor for content
2022-05-21 16:30:22 +02:00
allcontributors[bot]
439a07445e docs: update .all-contributorsrc [skip ci] 2022-05-21 14:30:14 +00:00
allcontributors[bot]
fedabf5f7f docs: update AUTHORS.md [skip ci] 2022-05-21 14:30:12 +00:00
diannasoreil
fdc3eb3b4e Merge pull request #1002 from lucasgrvarela/patch-1
Update info.toml - fix line number hint on exercise variables 1
2022-05-21 16:29:51 +02:00
Lucas Grigolon Varela
b0e079e6bf Update info.toml 2022-05-20 20:26:37 -03:00
diannasoreil
06cc363a46 Merge pull request #1001 from rust-lang/all-contributors/add-merelymyself
docs: add merelymyself as a contributor for code
2022-05-17 13:21:41 +02:00
allcontributors[bot]
47afcdcc6b docs: update .all-contributorsrc [skip ci] 2022-05-17 11:21:34 +00:00
allcontributors[bot]
c17177bdef docs: update AUTHORS.md [skip ci] 2022-05-17 11:21:33 +00:00
diannasoreil
8972e8f598 Merge pull request #1000 from merelymyself/patch-1
Checks for rustup install in install.sh.
2022-05-17 13:21:18 +02:00
pwygab
5b94016585 check for rustup install 2022-05-17 17:24:39 +08:00
diannasoreil
75b09dd69a Merge pull request #990 from rust-lang/all-contributors/add-nandajavarma
docs: add nandajavarma as a contributor for doc
2022-05-10 12:45:23 +02:00
allcontributors[bot]
89efbdf02d docs: update .all-contributorsrc [skip ci] 2022-05-10 10:45:14 +00:00
allcontributors[bot]
b8ff299399 docs: update AUTHORS.md [skip ci] 2022-05-10 10:45:13 +00:00
diannasoreil
b4510fc03b Merge pull request #989 from nandajavarma/main
remove deprecated user uploaded extension from .gitpod.yml
2022-05-10 12:44:51 +02:00
Nandaja Varma
769483640c remove deprecated user uploaded extension from .gitpod.yml 2022-05-09 19:40:30 +00:00
diannasoreil
aaccd6f7f3 Merge pull request #987 from likzn/fix/install_arr
fix(install.sh):fix `rust version` check
2022-05-06 16:42:09 +02:00
likzn
7027320a8f fix(install.sh):fix arr out of bounds 2022-05-04 00:46:49 +08:00
diannasoreil
b759ef6b58 Merge pull request #983 from rust-lang/all-contributors/add-liby
docs: add liby as a contributor for content
2022-04-27 12:22:28 +02:00
allcontributors[bot]
a18f3b8158 docs: update .all-contributorsrc [skip ci] 2022-04-27 10:22:20 +00:00
allcontributors[bot]
144e1ef018 docs: update AUTHORS.md [skip ci] 2022-04-27 10:22:19 +00:00
mokou
659a99032e chore: change branch name to main for cloning 2022-04-27 12:21:54 +02:00
diannasoreil
c5de2d686d Merge pull request #981 from liby/feature/replace-git-io-short-link
docs: replace git.io link with the original URL
2022-04-27 12:21:12 +02:00
Bryan Lee
13832d7726 docs: replace git.io link with the original URL 2022-04-27 00:51:25 +08:00
diannasoreil
b7cce5c050 Merge pull request #980 from rust-lang/all-contributors/add-luskwater
docs: add luskwater as a contributor for content
2022-04-25 11:38:27 +02:00
allcontributors[bot]
7a41bbca67 docs: update .all-contributorsrc [skip ci] 2022-04-25 09:38:19 +00:00
allcontributors[bot]
9e98b78260 docs: update AUTHORS.md [skip ci] 2022-04-25 09:38:18 +00:00
diannasoreil
604166f549 Merge pull request #975 from luskwater/scope-for-vogue
docs(move_semantics5): Replace "in vogue" with "in scope" in hint
2022-04-25 11:38:05 +02:00
diannasoreil
96b301c04e Merge pull request #979 from rust-lang/all-contributors/add-cuishuang
docs: add cuishuang as a contributor for content
2022-04-25 11:36:49 +02:00
allcontributors[bot]
190bb27d78 docs: update .all-contributorsrc [skip ci] 2022-04-25 09:36:31 +00:00
allcontributors[bot]
7eb66550c9 docs: update AUTHORS.md [skip ci] 2022-04-25 09:36:30 +00:00
diannasoreil
8f99209ab2 Merge pull request #976 from cuishuang/main
fix typo
2022-04-25 11:36:13 +02:00
cuishuang
701dd9c700 fix typo
Signed-off-by: cuishuang <imcusg@gmail.com>
2022-04-23 21:01:40 +08:00
Ron Lusk
b821ffdd33 docs(move_semantics5): Replace "in vogue" with "in scope" in hint
The hint for `move_semantics5` refers to "the range in which each
mutable reference is in vogue". Unless this is a deliberate
introduction of "vogue" (an admittedly-useful term because "scope"
isn't purely lexical, as in many other languages), it may be in error:
I have been unable to find the term used with reference to *Rust*
references.

Thus, I'm suggesting the replacement, in case it's been overlooked.
2022-04-22 09:04:36 -04:00
diannasoreil
102a4b92a0 Merge pull request #974 from rust-lang/all-contributors/add-rytheo
docs: add rytheo as a contributor for code
2022-04-21 11:37:00 +02:00
allcontributors[bot]
283a4691aa docs: update .all-contributorsrc [skip ci] 2022-04-21 09:36:53 +00:00
allcontributors[bot]
8dc696883e docs: update AUTHORS.md [skip ci] 2022-04-21 09:36:52 +00:00
diannasoreil
a6f50fd6f3 Merge pull request #484 from rytheo/progress-indicator
feat!: Add progress indicator
2022-04-21 11:36:38 +02:00
Ryan Lowe
6fae5d6114 Merge branch 'main' into progress-indicator 2022-04-20 23:29:47 -04:00
mokou
d2179d3e84 doc: update manual checkout version 2022-04-20 09:47:43 +02:00
mokou
9ec35d899c chore: bump version
Plus, remove the clog configuration file,
since that's not being used anymore.
2022-04-20 09:44:37 +02:00
mokou
c811643d1e chore: bump library versions 2022-04-20 09:35:08 +02:00
mokou
a259704570 Merge remote-tracking branch 'origin/main' 2022-04-20 09:21:01 +02:00
mokou
268822dbd8 chore: bump minimum required rust version in installs 2022-04-20 09:20:42 +02:00
diannasoreil
1237aa574c Merge pull request #969 from Fointard/fointard_using_as
refactor(using_as): improve readability by using sum() instead of fold()
2022-04-20 09:15:22 +02:00
diannasoreil
b3734ba310 Merge pull request #972 from rust-lang/all-contributors/add-Fointard
docs: add Fointard as a contributor for content
2022-04-20 09:14:35 +02:00
allcontributors[bot]
c9b73e412e docs: update .all-contributorsrc [skip ci] 2022-04-20 07:14:27 +00:00
allcontributors[bot]
107f1f97d9 docs: update AUTHORS.md [skip ci] 2022-04-20 07:14:26 +00:00
diannasoreil
420729da60 Merge pull request #968 from Fointard/fointard_arc1
refactor(arc1): improve readability by using functional style
2022-04-20 09:14:08 +02:00
fointard
452ab26aa7 refactor(using_as): improve readability by using sum() instead of fold() 2022-04-19 17:37:00 +02:00
fointard
92a5d0037f refactor(arc1): improve readability by using functional style 2022-04-19 17:11:27 +02:00
Ryan Lowe
9be012dda0 feat!: Add progress indicator
closes #360

BREAKING CHANGE: verify() has a new function signature so it can
know the current completion progress
2022-02-05 16:54:11 -05:00
18 changed files with 376 additions and 199 deletions

View File

@@ -1146,6 +1146,96 @@
"contributions": [
"content"
]
},
{
"login": "Fointard",
"name": "Fointard",
"avatar_url": "https://avatars.githubusercontent.com/u/9333398?v=4",
"profile": "https://github.com/Fointard",
"contributions": [
"content"
]
},
{
"login": "rytheo",
"name": "Ryan Lowe",
"avatar_url": "https://avatars.githubusercontent.com/u/22184325?v=4",
"profile": "https://github.com/rytheo",
"contributions": [
"code"
]
},
{
"login": "cuishuang",
"name": "cui fliter",
"avatar_url": "https://avatars.githubusercontent.com/u/15921519?v=4",
"profile": "http://www.dashen.tech",
"contributions": [
"content"
]
},
{
"login": "luskwater",
"name": "Ron Lusk",
"avatar_url": "https://avatars.githubusercontent.com/u/42529?v=4",
"profile": "https://github.com/luskwater",
"contributions": [
"content"
]
},
{
"login": "liby",
"name": "Bryan Lee",
"avatar_url": "https://avatars.githubusercontent.com/u/38807139?v=4",
"profile": "http://liby.github.io/liby/",
"contributions": [
"content"
]
},
{
"login": "nandajavarma",
"name": "Nandaja Varma",
"avatar_url": "https://avatars.githubusercontent.com/u/2624550?v=4",
"profile": "http://nandaja.space",
"contributions": [
"doc"
]
},
{
"login": "merelymyself",
"name": "pwygab",
"avatar_url": "https://avatars.githubusercontent.com/u/88221256?v=4",
"profile": "https://github.com/merelymyself",
"contributions": [
"code"
]
},
{
"login": "lucasgrvarela",
"name": "Lucas Grigolon Varela",
"avatar_url": "https://avatars.githubusercontent.com/u/37870368?v=4",
"profile": "http://linkedin.com/in/lucasgrvarela",
"contributions": [
"content"
]
},
{
"login": "bufo24",
"name": "Bufo",
"avatar_url": "https://avatars.githubusercontent.com/u/32884105?v=4",
"profile": "https://github.com/bufo24",
"contributions": [
"content"
]
},
{
"login": "jackos",
"name": "Jack Clayton",
"avatar_url": "https://avatars.githubusercontent.com/u/77730378?v=4",
"profile": "http://rustnote.com",
"contributions": [
"code"
]
}
],
"contributorsPerLine": 8,

View File

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

1
.gitignore vendored
View File

@@ -5,6 +5,7 @@ target/
*.pdb
exercises/clippy/Cargo.toml
exercises/clippy/Cargo.lock
rust-project.json
.idea
.vscode
*.iml

View File

@@ -4,4 +4,4 @@ tasks:
vscode:
extensions:
- rust-lang.rust@0.7.8:CvNqMTgDdt3UXt+6BCDTVg==
- rust-lang.rust@0.7.8

View File

@@ -164,6 +164,18 @@ authors.
<td align="center"><a href="https://github.com/ragreenburg"><img src="https://avatars.githubusercontent.com/u/24358100?v=4?s=100" width="100px;" alt=""/><br /><sub><b>ragreenburg</b></sub></a><br /><a href="#content-ragreenburg" title="Content">🖋</a></td>
<td align="center"><a href="https://github.com/stevenfukase"><img src="https://avatars.githubusercontent.com/u/66785624?v=4?s=100" width="100px;" alt=""/><br /><sub><b>stevenfukase</b></sub></a><br /><a href="#content-stevenfukase" title="Content">🖋</a></td>
<td align="center"><a href="https://github.com/J-S-Kim"><img src="https://avatars.githubusercontent.com/u/17569303?v=4?s=100" width="100px;" alt=""/><br /><sub><b>J-S-Kim</b></sub></a><br /><a href="#content-J-S-Kim" title="Content">🖋</a></td>
<td align="center"><a href="https://github.com/Fointard"><img src="https://avatars.githubusercontent.com/u/9333398?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Fointard</b></sub></a><br /><a href="#content-Fointard" title="Content">🖋</a></td>
<td align="center"><a href="https://github.com/rytheo"><img src="https://avatars.githubusercontent.com/u/22184325?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ryan Lowe</b></sub></a><br /><a href="https://github.com/rust-lang/rustlings/commits?author=rytheo" title="Code">💻</a></td>
<td align="center"><a href="http://www.dashen.tech"><img src="https://avatars.githubusercontent.com/u/15921519?v=4?s=100" width="100px;" alt=""/><br /><sub><b>cui fliter</b></sub></a><br /><a href="#content-cuishuang" title="Content">🖋</a></td>
<td align="center"><a href="https://github.com/luskwater"><img src="https://avatars.githubusercontent.com/u/42529?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ron Lusk</b></sub></a><br /><a href="#content-luskwater" title="Content">🖋</a></td>
</tr>
<tr>
<td align="center"><a href="http://liby.github.io/liby/"><img src="https://avatars.githubusercontent.com/u/38807139?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Bryan Lee</b></sub></a><br /><a href="#content-liby" title="Content">🖋</a></td>
<td align="center"><a href="http://nandaja.space"><img src="https://avatars.githubusercontent.com/u/2624550?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Nandaja Varma</b></sub></a><br /><a href="https://github.com/rust-lang/rustlings/commits?author=nandajavarma" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/merelymyself"><img src="https://avatars.githubusercontent.com/u/88221256?v=4?s=100" width="100px;" alt=""/><br /><sub><b>pwygab</b></sub></a><br /><a href="https://github.com/rust-lang/rustlings/commits?author=merelymyself" title="Code">💻</a></td>
<td align="center"><a href="http://linkedin.com/in/lucasgrvarela"><img src="https://avatars.githubusercontent.com/u/37870368?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Lucas Grigolon Varela</b></sub></a><br /><a href="#content-lucasgrvarela" title="Content">🖋</a></td>
<td align="center"><a href="https://github.com/bufo24"><img src="https://avatars.githubusercontent.com/u/32884105?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Bufo</b></sub></a><br /><a href="#content-bufo24" title="Content">🖋</a></td>
<td align="center"><a href="http://rustnote.com"><img src="https://avatars.githubusercontent.com/u/77730378?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jack Clayton</b></sub></a><br /><a href="https://github.com/rust-lang/rustlings/commits?author=jackos" title="Code">💻</a></td>
</tr>
</table>

View File

@@ -1,3 +1,45 @@
<a name="4.8.0"></a>
## 4.8.0 (2022-07-01)
#### Features
- Added a progress indicator for `rustlings watch`.
- The installation script now checks for Rustup being installed.
- Added a `rustlings lsp` command to enable `rust-analyzer`.
#### Bug Fixes
- **move_semantics5**: Replaced "in vogue" with "in scope" in hint.
- **if2**: Fixed a typo in the hint.
- **variables1**: Fixed an incorrect line reference in the hint.
- Fixed an out of bounds check in the installation Bash script.
#### Housekeeping
- Replaced the git.io URL with the fully qualified URL because of git.io's sunsetting.
- Removed the deprecated Rust GitPod extension.
<a name="4.7.1"></a>
## 4.7.1 (2022-04-20)
#### Features
- The amount of dependency crates that need to be compiled went down from ~65 to
~45 by bumping dependency versions.
- The minimum Rust version in the install scripts has been bumped to 1.56.0 (this isn't in
the release itself, since install scripts don't really get versioned)
#### Bug Fixes
- **arc1**: A small part has been rewritten using a more functional code style (#968).
- **using_as**: A small part has been refactored to use `sum` instead of `fold`, resulting
in better readability.
#### Housekeeping
- The changelog will now be manually written instead of being automatically generated by the
Git log.
<a name="4.7.0"></a>
## 4.7.0 (2022-04-14)
@@ -264,7 +306,7 @@
#### 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 exercise 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))

155
Cargo.lock generated
View File

@@ -52,17 +52,6 @@ dependencies = [
"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"
@@ -87,45 +76,15 @@ 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"
version = "0.15.0"
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"
checksum = "a28b32d32ca44b70c3e4acd7db1babf555fa026e385fb95f18028f88848b3c31"
dependencies = [
"encode_unicode",
"lazy_static",
"libc",
"once_cell",
"regex",
"terminal_size",
"unicode-width",
@@ -228,24 +187,23 @@ dependencies = [
]
[[package]]
name = "hermit-abi"
version = "0.1.19"
name = "home"
version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
checksum = "2456aef2e6b6a9784192ae780c0f15bc57df0e918585282325e8c8ac27737654"
dependencies = [
"libc",
"winapi 0.3.9",
]
[[package]]
name = "indicatif"
version = "0.10.3"
version = "0.16.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "40ecd1e2ee08e6c255ce890f5a99d17000850e664e7acf119fb03b25b0575bfe"
checksum = "2d207dc617c7a380ab07ff572a6e52fa202a2a8f355860ac9c38e23f8196be1b"
dependencies = [
"console 0.14.1",
"console",
"lazy_static",
"number_prefix",
"parking_lot",
"regex",
]
@@ -269,15 +227,6 @@ dependencies = [
"libc",
]
[[package]]
name = "instant"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bee0328b1209d157ef001c94dd85b4f8f64139adb0eac2659f4b08382b2f474d"
dependencies = [
"cfg-if 1.0.0",
]
[[package]]
name = "iovec"
version = "0.1.4"
@@ -289,9 +238,9 @@ dependencies = [
[[package]]
name = "itoa"
version = "0.4.8"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4"
checksum = "112c678d4050afce233f4f2852bb2eb519230b3cf12f33585275537d7e41578d"
[[package]]
name = "kernel32-sys"
@@ -321,15 +270,6 @@ version = "0.2.100"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1fa8cddc8fbbee11227ef194b5317ed014b8acbf15139bd716a18ad3fe99ec5"
[[package]]
name = "lock_api"
version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0382880606dff6d15c9476c416d18690b72742aa7b605bb6dd6ec9030fbf07eb"
dependencies = [
"scopeguard",
]
[[package]]
name = "log"
version = "0.4.14"
@@ -434,37 +374,15 @@ dependencies = [
[[package]]
name = "number_prefix"
version = "0.2.8"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dbf9993e59c894e3c08aa1c2712914e9e6bf1fcbfc6bef283e2183df345a4fee"
dependencies = [
"num-traits",
]
checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3"
[[package]]
name = "parking_lot"
version = "0.11.1"
name = "once_cell"
version = "1.10.0"
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",
]
checksum = "87f3e037eac156d1775da914196f0f37741a274155e34a0b7e427c35d2a2ecb9"
[[package]]
name = "predicates"
@@ -524,9 +442,9 @@ dependencies = [
[[package]]
name = "regex"
version = "1.5.4"
version = "1.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461"
checksum = "1a11647b6b25ff05a515cb92c365cec08801e83423a235b51e231e1808747286"
dependencies = [
"aho-corasick",
"memchr",
@@ -541,17 +459,19 @@ checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b"
[[package]]
name = "rustlings"
version = "4.7.0"
version = "4.7.1"
dependencies = [
"argh",
"assert_cmd",
"console 0.7.7",
"console",
"glob",
"home",
"indicatif",
"notify",
"predicates",
"regex",
"serde",
"serde_json",
"toml",
]
@@ -570,12 +490,6 @@ 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.129"
@@ -598,9 +512,9 @@ dependencies = [
[[package]]
name = "serde_json"
version = "1.0.66"
version = "1.0.81"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "336b10da19a12ad094b59d870ebde26a45402e5b470add4b5fd03c5048a32127"
checksum = "9b7ce2b32a1aed03c558dc61a5cd328f15aff2dbc17daad8fb8af04d2100e15c"
dependencies = [
"itoa",
"ryu",
@@ -613,12 +527,6 @@ version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c307a32c1c5c437f38c7fd45d753050587732ba8628319fbdf12a7e289ccc590"
[[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.75"
@@ -640,20 +548,11 @@ dependencies = [
"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"
version = "0.5.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "758664fc71a3a69038656bee8b6be6477d2a6c315a6b81f7081f591bffa4111f"
checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7"
dependencies = [
"serde",
]

View File

@@ -1,17 +1,20 @@
[package]
name = "rustlings"
version = "4.7.0"
version = "4.8.0"
authors = ["mokou <mokou@fastmail.com>", "Carol (Nichols || Goulding) <carol.nichols@gmail.com>"]
edition = "2021"
[dependencies]
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"] }
argh = "0.1"
indicatif = "0.16"
console = "0.15"
notify = "4.0"
toml = "0.5"
regex = "1.5"
serde= { version = "1.0", features = ["derive"] }
serde_json = "1.0.81"
home = "0.5.3"
glob = "0.3.0"
[[bin]]
name = "rustlings"

View File

@@ -21,9 +21,9 @@ You will need to have Rust installed. You can get it by visiting https://rustup.
Just run:
```bash
curl -L https://git.io/install-rustlings | bash
curl -L https://raw.githubusercontent.com/rust-lang/rustlings/main/install.sh | bash
# Or if you want it to be installed to a different path:
curl -L https://git.io/install-rustlings | bash -s mypath/
curl -L https://raw.githubusercontent.com/rust-lang/rustlings/main/install.sh | bash -s mypath/
```
This will install Rustlings and give you access to the `rustlings` command. Run it to get started!
@@ -39,7 +39,7 @@ Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
Then, you can run:
```ps1
Start-BitsTransfer -Source https://git.io/JTL5v -Destination $env:TMP/install_rustlings.ps1; Unblock-File $env:TMP/install_rustlings.ps1; Invoke-Expression $env:TMP/install_rustlings.ps1
Start-BitsTransfer -Source https://raw.githubusercontent.com/rust-lang/rustlings/main/install.ps1 -Destination $env:TMP/install_rustlings.ps1; Unblock-File $env:TMP/install_rustlings.ps1; Invoke-Expression $env:TMP/install_rustlings.ps1
```
To install Rustlings. Same as on MacOS/Linux, you will have access to the `rustlings` command after it.
@@ -50,15 +50,15 @@ When you get a permission denied message then you have to exclude the directory
[Run on Repl.it](https://repl.it/github/rust-lang/rustlings)
[Open in Gitpod](https://gitpod.io/#https://github.com/rust-lang/rustlings)
[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/rust-lang/rustlings)
## Manually
Basically: Clone the repository at the latest tag, run `cargo install`.
```bash
# find out the latest version at https://github.com/rust-lang/rustlings/releases/latest (on edit 4.6.0)
git clone -b 4.6.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 4.7.1)
git clone -b 4.7.1 --depth 1 https://github.com/rust-lang/rustlings
cd rustlings
cargo install --force --path .
```
@@ -126,24 +126,7 @@ After every couple of sections, there will be a quiz that'll test your knowledge
## Enabling `rust-analyzer`
`rust-analyzer` support is provided, but it depends on your editor
whether it's enabled by default. (RLS support is not provided)
To enable `rust-analyzer`, you'll need to make Cargo build the project
with the `exercises` feature, which will automatically include the `exercises/`
subfolder in the project. The easiest way to do this is to tell your editor to
build the project with all features (the equivalent of `cargo build --all-features`).
For specific editor instructions:
- **VSCode**: Add a `.vscode/settings.json` file with the following:
```json
{
"rust-analyzer.cargo.features": ["exercises"]
}
```
- **IntelliJ-based Editors**: Using the Rust plugin, everything should work
by default.
- _Missing your editor? Feel free to contribute more instructions!_
Run the command `rustlings lsp` which will generate a `rust-project.json` at the root of the project, this allows [rust-analyzer](https://rust-analyzer.github.io/) to parse each exercise.
## Continuing On

View File

@@ -8,7 +8,7 @@
// I AM NOT DONE
fn average(values: &[f64]) -> f64 {
let total = values.iter().fold(0.0, |a, b| a + b);
let total = values.iter().sum::<f64>();
total / values.len()
}

View File

@@ -32,12 +32,7 @@ fn main() {
for offset in 0..8 {
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 += 8;
}
let sum: u32 = child_numbers.iter().filter(|n| *n % 8 == offset).sum();
println!("Sum of offset {} is {}", offset, sum);
}));
}

View File

@@ -21,7 +21,7 @@ name = "variables1"
path = "exercises/variables/variables1.rs"
mode = "compile"
hint = """
Hint: The declaration on line 12 is missing a keyword that is needed in Rust
Hint: The declaration on line 8 is missing a keyword that is needed in Rust
to create a new variable binding."""
[[exercises]]
@@ -158,7 +158,7 @@ path = "exercises/if/if2.rs"
mode = "test"
hint = """
For that first compiler error, it's important in Rust that each conditional
block return the same type! To get the tests passing, you will need a couple
block returns the same type! To get the tests passing, you will need a couple
conditions checking different input values."""
# TEST 1
@@ -231,7 +231,7 @@ path = "exercises/move_semantics/move_semantics5.rs"
mode = "compile"
hint = """
Carefully reason about the range in which each mutable reference is in
vogue. Does it help to update the value of referent (x) immediately after
scope. Does it help to update the value of referent (x) immediately after
the mutable reference is taken? Read more about 'Mutable References'
in the book's section References and Borrowing':
https://doc.rust-lang.org/book/ch04-02-references-and-borrowing.html#mutable-references.

View File

@@ -53,7 +53,7 @@ function vercomp($v1, $v2) {
}
$rustVersion = $(rustc --version).Split(" ")[1]
$minRustVersion = "1.39"
$minRustVersion = "1.56"
if ((vercomp $rustVersion $minRustVersion) -eq 2) {
Write-Host "WARNING: Rust version is too old: $rustVersion - needs at least $minRustVersion"
Write-Host "Please update Rust with 'rustup update'"

View File

@@ -25,12 +25,21 @@ else
exit 1
fi
if [ -x "$(command -v rustup)" ]
then
echo "SUCCESS: rustup is installed"
else
echo "ERROR: rustup does not seem to be installed."
echo "Please download rustup using https://rustup.rs!"
exit 1
fi
if [ -x "$(command -v rustc)" ]
then
echo "SUCCESS: Rust is installed"
else
echo "ERROR: Rust does not seem to be installed."
echo "Please download Rust using https://rustup.rs!"
echo "Please download Rust using rustup!"
exit 1
fi
@@ -39,7 +48,7 @@ then
echo "SUCCESS: Cargo is installed"
else
echo "ERROR: Cargo does not seem to be installed."
echo "Please download Rust and Cargo using https://rustup.rs!"
echo "Please download Rust and Cargo using rustup!"
exit 1
fi
@@ -75,6 +84,21 @@ function vercomp() {
then
max_len=$len2
fi
#pad right in short arr
if [[ len1 -gt len2 ]];
then
for ((i = len2; i < len1; i++));
do
v2[$i]=0
done
else
for ((i = len1; i < len2; i++));
do
v1[$i]=0
done
fi
for i in `seq 0 $max_len`
do
# Fill empty fields with zeros in v1
@@ -100,7 +124,7 @@ function vercomp() {
}
RustVersion=$(rustc --version | cut -d " " -f 2)
MinRustVersion=1.39
MinRustVersion=1.56
vercomp "$RustVersion" $MinRustVersion || ec=$?
if [ ${ec:-0} -eq 2 ]
then

View File

@@ -1,4 +1,5 @@
use crate::exercise::{Exercise, ExerciseList};
use crate::project::RustAnalyzerProject;
use crate::run::run;
use crate::verify::verify;
use argh::FromArgs;
@@ -20,11 +21,12 @@ use std::time::Duration;
mod ui;
mod exercise;
mod project;
mod run;
mod verify;
// In sync with crate version
const VERSION: &str = "4.7.0";
const VERSION: &str = "4.8.0";
#[derive(FromArgs, PartialEq, Debug)]
/// Rustlings is a collection of small exercises to get you used to writing and reading Rust code
@@ -47,6 +49,7 @@ enum Subcommands {
Run(RunArgs),
Hint(HintArgs),
List(ListArgs),
Lsp(LspArgs),
}
#[derive(FromArgs, PartialEq, Debug)]
@@ -77,6 +80,12 @@ struct HintArgs {
name: String,
}
#[derive(FromArgs, PartialEq, Debug)]
#[argh(subcommand, name = "lsp")]
/// Enable rust-analyzer for exercises
struct LspArgs {}
#[derive(FromArgs, PartialEq, Debug)]
#[argh(subcommand, name = "list")]
/// Lists the exercises available in Rustlings
@@ -203,7 +212,26 @@ fn main() {
}
Subcommands::Verify(_subargs) => {
verify(&exercises, verbose).unwrap_or_else(|_| std::process::exit(1));
verify(&exercises, (0, exercises.len()), verbose).unwrap_or_else(|_| std::process::exit(1));
}
Subcommands::Lsp(_subargs) => {
let mut project = RustAnalyzerProject::new();
project
.get_sysroot_src()
.expect("Couldn't find toolchain path, do you have `rustc` installed?");
project
.exercies_to_json()
.expect("Couldn't parse rustlings exercises files");
if project.crates.is_empty() {
println!("Failed find any exercises, make sure you're in the `rustlings` folder");
} else if project.write_to_disk().is_err() {
println!("Failed to write rust-project.json to disk for rust-analyzer");
} else {
println!("Successfully generated rust-project.json");
println!("rust-analyzer will now parse exercises, restart your language server or editor")
}
}
Subcommands::Watch(_subargs) => match watch(&exercises, verbose) {
@@ -224,6 +252,7 @@ fn main() {
}
}
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.");
@@ -295,7 +324,7 @@ fn watch(exercises: &[Exercise], verbose: bool) -> notify::Result<WatchStatus> {
clear_screen();
let to_owned_hint = |t: &Exercise| t.hint.to_owned();
let failed_exercise_hint = match verify(exercises.iter(), verbose) {
let failed_exercise_hint = match verify(exercises.iter(), (0, exercises.len()), verbose) {
Ok(_) => return Ok(WatchStatus::Finished),
Err(exercise) => Arc::new(Mutex::new(Some(to_owned_hint(exercise)))),
};
@@ -308,11 +337,11 @@ fn watch(exercises: &[Exercise], verbose: bool) -> notify::Result<WatchStatus> {
let filepath = b.as_path().canonicalize().unwrap();
let pending_exercises = exercises
.iter()
.skip_while(|e| !filepath.ends_with(&e.path))
// .filter(|e| 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, verbose) {
match verify(pending_exercises, (num_done, exercises.len()), verbose) {
Ok(_) => return Ok(WatchStatus::Finished),
Err(exercise) => {
let mut failed_exercise_hint = failed_exercise_hint.lock().unwrap();
@@ -367,6 +396,8 @@ started, here's a couple of notes about how Rustlings operates:
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!
5. If you want to use `rust-analyzer` with exercises, which provides features like
autocompletion, run the command `rustlings lsp`.
Got all that? Great! To get started, run `rustlings watch` in order to get the first
exercise. Make sure to have your editor open!"#;

90
src/project.rs Normal file
View File

@@ -0,0 +1,90 @@
use glob::glob;
use serde::{Deserialize, Serialize};
use std::error::Error;
use std::process::Command;
/// Contains the structure of resulting rust-project.json file
/// and functions to build the data required to create the file
#[derive(Serialize, Deserialize)]
pub struct RustAnalyzerProject {
sysroot_src: String,
pub crates: Vec<Crate>,
}
#[derive(Serialize, Deserialize)]
pub struct Crate {
root_module: String,
edition: String,
deps: Vec<String>,
cfg: Vec<String>,
}
impl RustAnalyzerProject {
pub fn new() -> RustAnalyzerProject {
RustAnalyzerProject {
sysroot_src: String::new(),
crates: Vec::new(),
}
}
/// Write rust-project.json to disk
pub fn write_to_disk(&self) -> Result<(), std::io::Error> {
std::fs::write(
"./rust-project.json",
serde_json::to_vec(&self).expect("Failed to serialize to JSON"),
)?;
Ok(())
}
/// If path contains .rs extension, add a crate to `rust-project.json`
fn path_to_json(&mut self, path: String) {
if let Some((_, ext)) = path.split_once('.') {
if ext == "rs" {
self.crates.push(Crate {
root_module: path,
edition: "2021".to_string(),
deps: Vec::new(),
// This allows rust_analyzer to work inside #[test] blocks
cfg: vec!["test".to_string()],
})
}
}
}
/// Parse the exercises folder for .rs files, any matches will create
/// a new `crate` in rust-project.json which allows rust-analyzer to
/// treat it like a normal binary
pub fn exercies_to_json(&mut self) -> Result<(), Box<dyn Error>> {
for e in glob("./exercises/**/*")? {
let path = e?.to_string_lossy().to_string();
self.path_to_json(path);
}
Ok(())
}
/// Use `rustc` to determine the default toolchain
pub fn get_sysroot_src(&mut self) -> Result<(), Box<dyn Error>> {
let toolchain = Command::new("rustc")
.arg("--print")
.arg("sysroot")
.output()?
.stdout;
let toolchain = String::from_utf8_lossy(&toolchain);
let mut whitespace_iter = toolchain.split_whitespace();
let toolchain = whitespace_iter.next().unwrap_or(&toolchain);
println!("Determined toolchain: {}\n", &toolchain);
self.sysroot_src = (std::path::Path::new(&*toolchain)
.join("lib")
.join("rustlib")
.join("src")
.join("rust")
.join("library")
.to_string_lossy())
.to_string();
Ok(())
}
}

View File

@@ -20,7 +20,7 @@ pub fn run(exercise: &Exercise, verbose: bool) -> Result<(), ()> {
// This is strictly for non-test binaries, so output is displayed
fn compile_and_run(exercise: &Exercise) -> Result<(), ()> {
let progress_bar = ProgressBar::new_spinner();
progress_bar.set_message(format!("Compiling {}...", exercise).as_str());
progress_bar.set_message(format!("Compiling {}...", exercise));
progress_bar.enable_steady_tick(100);
let compilation_result = exercise.compile();
@@ -37,7 +37,7 @@ fn compile_and_run(exercise: &Exercise) -> Result<(), ()> {
}
};
progress_bar.set_message(format!("Running {}...", exercise).as_str());
progress_bar.set_message(format!("Running {}...", exercise));
let result = compilation.run();
progress_bar.finish_and_clear();

View File

@@ -1,6 +1,6 @@
use crate::exercise::{CompiledExercise, Exercise, Mode, State};
use console::style;
use indicatif::ProgressBar;
use indicatif::{ProgressBar, ProgressStyle};
use std::env;
// Verify that the provided container of Exercise objects
@@ -9,10 +9,18 @@ use std::env;
// If the Exercise being verified is a test, the verbose boolean
// determines whether or not the test harness outputs are displayed.
pub fn verify<'a>(
start_at: impl IntoIterator<Item = &'a Exercise>,
exercises: impl IntoIterator<Item = &'a Exercise>,
progress: (usize, usize),
verbose: bool,
) -> Result<(), &'a Exercise> {
for exercise in start_at {
let (num_done, total) = progress;
let bar = ProgressBar::new(total as u64);
bar.set_style(ProgressStyle::default_bar()
.template("Progress: [{bar:60.green/red}] {pos}/{len}")
.progress_chars("#>-")
);
bar.set_position(num_done as u64);
for exercise in exercises {
let compile_result = match exercise.mode {
Mode::Test => compile_and_test(exercise, RunMode::Interactive, verbose),
Mode::Compile => compile_and_run_interactively(exercise),
@@ -21,6 +29,7 @@ pub fn verify<'a>(
if !compile_result.unwrap_or(false) {
return Err(exercise);
}
bar.inc(1);
}
Ok(())
}
@@ -39,25 +48,24 @@ pub fn test(exercise: &Exercise, verbose: bool) -> Result<(), ()> {
// Invoke the rust compiler without running the resulting binary
fn compile_only(exercise: &Exercise) -> Result<bool, ()> {
let progress_bar = ProgressBar::new_spinner();
progress_bar.set_message(format!("Compiling {}...", exercise).as_str());
progress_bar.set_message(format!("Compiling {}...", exercise));
progress_bar.enable_steady_tick(100);
let _ = compile(exercise, &progress_bar)?;
progress_bar.finish_and_clear();
success!("Successfully compiled {}!", exercise);
Ok(prompt_for_completion(exercise, None))
}
// Compile the given Exercise and run the resulting binary in an interactive mode
fn compile_and_run_interactively(exercise: &Exercise) -> Result<bool, ()> {
let progress_bar = ProgressBar::new_spinner();
progress_bar.set_message(format!("Compiling {}...", exercise).as_str());
progress_bar.set_message(format!("Compiling {}...", exercise));
progress_bar.enable_steady_tick(100);
let compilation = compile(exercise, &progress_bar)?;
progress_bar.set_message(format!("Running {}...", exercise).as_str());
progress_bar.set_message(format!("Running {}...", exercise));
let result = compilation.run();
progress_bar.finish_and_clear();
@@ -71,8 +79,6 @@ fn compile_and_run_interactively(exercise: &Exercise) -> Result<bool, ()> {
}
};
success!("Successfully ran {}!", exercise);
Ok(prompt_for_completion(exercise, Some(output.stdout)))
}
@@ -80,7 +86,7 @@ fn compile_and_run_interactively(exercise: &Exercise) -> Result<bool, ()> {
// the output if verbose is set to true
fn compile_and_test(exercise: &Exercise, run_mode: RunMode, verbose: bool) -> Result<bool, ()> {
let progress_bar = ProgressBar::new_spinner();
progress_bar.set_message(format!("Testing {}...", exercise).as_str());
progress_bar.set_message(format!("Testing {}...", exercise));
progress_bar.enable_steady_tick(100);
let compilation = compile(exercise, &progress_bar)?;
@@ -92,7 +98,6 @@ fn compile_and_test(exercise: &Exercise, run_mode: RunMode, verbose: bool) -> Re
if verbose {
println!("{}", output.stdout);
}
success!("Successfully tested {}", &exercise);
if let RunMode::Interactive = run_mode {
Ok(prompt_for_completion(exercise, None))
} else {
@@ -138,6 +143,12 @@ fn prompt_for_completion(exercise: &Exercise, prompt_output: Option<String>) ->
State::Pending(context) => context,
};
match exercise.mode {
Mode::Compile => success!("Successfully ran {}!", exercise),
Mode::Test => success!("Successfully tested {}!", exercise),
Mode::Clippy => success!("Successfully compiled {}!", exercise),
}
let no_emoji = env::var("NO_EMOJI").is_ok();
let clippy_success_msg = if no_emoji {