From 83ac243c00d0b99c6d038546a4ffda2d5b23ca07 Mon Sep 17 00:00:00 2001 From: Ofir Lauber Date: Thu, 21 Sep 2023 01:32:46 +0300 Subject: [PATCH 01/32] chore: fix comment in enums3.rs --- exercises/enums/enums3.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/exercises/enums/enums3.rs b/exercises/enums/enums3.rs index 2dcdad06..92d18c46 100644 --- a/exercises/enums/enums3.rs +++ b/exercises/enums/enums3.rs @@ -41,10 +41,9 @@ impl State { } fn process(&mut self, message: Message) { - // TODO: create a match expression to process the different message - // variants - // Remember: When passing a tuple as a function argument, you'll need - // extra parentheses: fn function((t, u, p, l, e)) + // TODO: create a match expression to process the different message variants + // Remember: When passing a tuple as a function argument, you'll need extra parentheses: + // fn function((t, u, p, l, e)) } } From 666857dc4eb7f1187f40d5631dbf1a10d63ac2cb Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Thu, 21 Sep 2023 10:01:30 +0000 Subject: [PATCH 02/32] docs: update AUTHORS.md [skip ci] --- AUTHORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS.md b/AUTHORS.md index fb249acb..51255a9a 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -343,6 +343,7 @@ authors. Luka Krmpotiฤ‡
Luka Krmpotiฤ‡

๐Ÿ–‹ Jurglic
Jurglic

๐Ÿ–‹ + Ofir Lauber
Ofir Lauber

๐Ÿ–‹ From f86a3c5ddcf29c01c9c4308e2556cf3cc35917de Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Thu, 21 Sep 2023 10:01:31 +0000 Subject: [PATCH 03/32] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 92bf2a09..d2ad2529 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -2424,6 +2424,15 @@ "contributions": [ "content" ] + }, + { + "login": "OfirLauber", + "name": "Ofir Lauber", + "avatar_url": "https://avatars.githubusercontent.com/u/5631030?v=4", + "profile": "https://github.com/OfirLauber", + "contributions": [ + "content" + ] } ], "contributorsPerLine": 8, From c63c44ac70667c0696997a6f40efbf9239789d18 Mon Sep 17 00:00:00 2001 From: Chris Rose Date: Thu, 21 Sep 2023 11:00:04 -0600 Subject: [PATCH 04/32] Remove .envrc --- .envrc | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 .envrc diff --git a/.envrc b/.envrc deleted file mode 100644 index 48541064..00000000 --- a/.envrc +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash - -# Automatically Load nix devShell w/dotenv -use flake From 6aa47be78e9b80beec3bdd5b96a8f985138358b2 Mon Sep 17 00:00:00 2001 From: d1t2 <507502+dieterplex@users.noreply.github.com> Date: Fri, 22 Sep 2023 11:32:39 +0800 Subject: [PATCH 05/32] fix(installation): bump MinRustVersion to 1.70 Since #1633 porting to Clap, min Rust version reqirement changes. --- install.ps1 | 2 +- install.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/install.ps1 b/install.ps1 index 7bab21f6..844b0134 100644 --- a/install.ps1 +++ b/install.ps1 @@ -53,7 +53,7 @@ function vercomp($v1, $v2) { } $rustVersion = $(rustc --version).Split(" ")[1] -$minRustVersion = "1.56" +$minRustVersion = "1.70" 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'" diff --git a/install.sh b/install.sh index 4ee56bb1..9aca5b68 100755 --- a/install.sh +++ b/install.sh @@ -124,7 +124,7 @@ function vercomp() { } RustVersion=$(rustc --version | cut -d " " -f 2) -MinRustVersion=1.58 +MinRustVersion=1.70 vercomp "$RustVersion" $MinRustVersion || ec=$? if [ ${ec:-0} -eq 2 ] then From b88c23897f27ff5aa7d700f0bc16a289068445d5 Mon Sep 17 00:00:00 2001 From: jyn Date: Mon, 25 Sep 2023 03:36:43 -0400 Subject: [PATCH 06/32] Give a more helpful error when a file is missing Previously, this would just say "missing file". Now it shows the path of the file that was missing, which should make it easier to debug what went wrong. --- src/exercise.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/exercise.rs b/src/exercise.rs index 07251dba..2c740fbf 100644 --- a/src/exercise.rs +++ b/src/exercise.rs @@ -201,14 +201,21 @@ path = "{}.rs""#, } pub fn state(&self) -> State { - let mut source_file = - File::open(&self.path).expect("We were unable to open the exercise file!"); + let mut source_file = File::open(&self.path).unwrap_or_else(|e| { + panic!( + "We were unable to open the exercise file {}! {e}", + self.path.display() + ) + }); let source = { let mut s = String::new(); - source_file - .read_to_string(&mut s) - .expect("We were unable to read the exercise file!"); + source_file.read_to_string(&mut s).unwrap_or_else(|e| { + panic!( + "We were unable to read the exercise file {}! {e}", + self.path.display() + ) + }); s }; From be78831ac02f969f02f4c2f35193dd2a2bb3aa62 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Tue, 26 Sep 2023 08:58:45 +0000 Subject: [PATCH 07/32] docs: update AUTHORS.md [skip ci] --- AUTHORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS.md b/AUTHORS.md index 51255a9a..09d74809 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -344,6 +344,7 @@ authors. Luka Krmpotiฤ‡
Luka Krmpotiฤ‡

๐Ÿ–‹ Jurglic
Jurglic

๐Ÿ–‹ Ofir Lauber
Ofir Lauber

๐Ÿ–‹ + Chris Rose
Chris Rose

๐Ÿš‡ From e58c8322e90f8435b9e5a7adaaebaeec2fe10c3d Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Tue, 26 Sep 2023 08:58:46 +0000 Subject: [PATCH 08/32] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index d2ad2529..0239dd42 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -2433,6 +2433,15 @@ "contributions": [ "content" ] + }, + { + "login": "offbyone", + "name": "Chris Rose", + "avatar_url": "https://avatars.githubusercontent.com/u/181693?v=4", + "profile": "https://github.com/offbyone", + "contributions": [ + "infra" + ] } ], "contributorsPerLine": 8, From 463e23e006a314d80139afe6a9144a34d6de358a Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Tue, 26 Sep 2023 08:59:25 +0000 Subject: [PATCH 09/32] docs: update AUTHORS.md [skip ci] --- AUTHORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS.md b/AUTHORS.md index 51255a9a..1ee1bf7e 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -344,6 +344,7 @@ authors. Luka Krmpotiฤ‡
Luka Krmpotiฤ‡

๐Ÿ–‹ Jurglic
Jurglic

๐Ÿ–‹ Ofir Lauber
Ofir Lauber

๐Ÿ–‹ + d1t2
d1t2

๐Ÿš‡ From 00e16b49e576adfebf34b45c4d7492595656246c Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Tue, 26 Sep 2023 08:59:26 +0000 Subject: [PATCH 10/32] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index d2ad2529..0bf80fce 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -2433,6 +2433,15 @@ "contributions": [ "content" ] + }, + { + "login": "dieterplex", + "name": "d1t2", + "avatar_url": "https://avatars.githubusercontent.com/u/507502?v=4", + "profile": "https://github.com/dieterplex", + "contributions": [ + "infra" + ] } ], "contributorsPerLine": 8, From cc658eb28840e63f69f89c8562bbf10333461355 Mon Sep 17 00:00:00 2001 From: DocWilco Date: Wed, 27 Sep 2023 21:33:49 +0200 Subject: [PATCH 11/32] fix(cli): make debugging in windows work On windows, if `stderr` or `stdin` aren't also set to `Stdio::null()` the `spawn()` fails with `The handle is invalid`, and `rustlings` thinks that there's no `rustc` installed. --- src/main.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main.rs b/src/main.rs index a4b764d7..89bd444f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -396,6 +396,8 @@ fn rustc_exists() -> bool { Command::new("rustc") .args(["--version"]) .stdout(Stdio::null()) + .stderr(Stdio::null()) + .stdin(Stdio::null()) .spawn() .and_then(|mut child| child.wait()) .map(|status| status.success()) From 511e3343650a880435f8fb3e96eecbc674d6ebfa Mon Sep 17 00:00:00 2001 From: DocWilco Date: Wed, 27 Sep 2023 22:02:14 +0200 Subject: [PATCH 12/32] fix(cli): stop littering pdb files on windows --- src/exercise.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/exercise.rs b/src/exercise.rs index 2c740fbf..c7b5672d 100644 --- a/src/exercise.rs +++ b/src/exercise.rs @@ -9,6 +9,7 @@ use std::process::{self, Command}; const RUSTC_COLOR_ARGS: &[&str] = &["--color", "always"]; const RUSTC_EDITION_ARGS: &[&str] = &["--edition", "2021"]; +const RUSTC_NO_DEBUG_ARGS: &[&str] = &["-C", "strip=debuginfo"]; const I_AM_DONE_REGEX: &str = r"(?m)^\s*///?\s*I\s+AM\s+NOT\s+DONE"; const CONTEXT: usize = 2; const CLIPPY_CARGO_TOML_PATH: &str = "./exercises/clippy/Cargo.toml"; @@ -113,11 +114,13 @@ impl Exercise { .args([self.path.to_str().unwrap(), "-o", &temp_file()]) .args(RUSTC_COLOR_ARGS) .args(RUSTC_EDITION_ARGS) + .args(RUSTC_NO_DEBUG_ARGS) .output(), Mode::Test => Command::new("rustc") .args(["--test", self.path.to_str().unwrap(), "-o", &temp_file()]) .args(RUSTC_COLOR_ARGS) .args(RUSTC_EDITION_ARGS) + .args(RUSTC_NO_DEBUG_ARGS) .output(), Mode::Clippy => { let cargo_toml = format!( @@ -144,6 +147,7 @@ path = "{}.rs""#, .args([self.path.to_str().unwrap(), "-o", &temp_file()]) .args(RUSTC_COLOR_ARGS) .args(RUSTC_EDITION_ARGS) + .args(RUSTC_NO_DEBUG_ARGS) .output() .expect("Failed to compile!"); // Due to an issue with Clippy, a cargo clean is required to catch all lints. @@ -289,6 +293,24 @@ mod test { assert!(!Path::new(&temp_file()).exists()); } + #[test] + #[cfg(target_os = "windows")] + fn test_no_pdb_file() { + [Mode::Compile, Mode::Test] // Clippy doesn't like to test + .iter() + .for_each(|mode| { + let exercise = Exercise { + name: String::from("example"), + // We want a file that does actually compile + path: PathBuf::from("tests/fixture/state/pending_exercise.rs"), + mode: *mode, + hint: String::from(""), + }; + let _ = exercise.compile().unwrap(); + assert!(!Path::new(&format!("{}.pdb", temp_file())).exists()); + }); + } + #[test] fn test_pending_state() { let exercise = Exercise { From 177981d1cd4812dd7b67d4fc7f74227e21f1691b Mon Sep 17 00:00:00 2001 From: liv Date: Thu, 28 Sep 2023 11:02:25 +0200 Subject: [PATCH 13/32] chore: fix missing opening brace --- .all-contributorsrc | 1 + 1 file changed, 1 insertion(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 27f69c3b..d8aeff54 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -2443,6 +2443,7 @@ "infra" ] }, + { "login": "dieterplex", "name": "d1t2", "avatar_url": "https://avatars.githubusercontent.com/u/507502?v=4", From 11227403cecec2cb27fc9d3758ccb2962b352002 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Thu, 28 Sep 2023 09:02:43 +0000 Subject: [PATCH 14/32] docs: update AUTHORS.md [skip ci] --- AUTHORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS.md b/AUTHORS.md index a2decea4..3dcc3e6f 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -346,6 +346,7 @@ authors. Ofir Lauber
Ofir Lauber

๐Ÿ–‹ Chris Rose
Chris Rose

๐Ÿš‡ d1t2
d1t2

๐Ÿš‡ + docwilco
docwilco

๐Ÿ’ป From 2fcafc66020fbe169efd4ff948d751f7be9a1b98 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Thu, 28 Sep 2023 09:02:44 +0000 Subject: [PATCH 15/32] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index d8aeff54..d31607fd 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -2451,6 +2451,15 @@ "contributions": [ "infra" ] + }, + { + "login": "docwilco", + "name": "docwilco", + "avatar_url": "https://avatars.githubusercontent.com/u/66911096?v=4", + "profile": "https://github.com/docwilco", + "contributions": [ + "code" + ] } ], "contributorsPerLine": 8, From 8e6c83b4cf8e61ad8a0fbbb42bdf968e93278736 Mon Sep 17 00:00:00 2001 From: Rogier 'DocWilco' Mulhuijzen Date: Fri, 29 Sep 2023 00:39:51 +0200 Subject: [PATCH 16/32] chore: make hints proper markdown Also rewrapped some hints to 80 columns so that they also look good in a terminal. closes #1698 --- info.toml | 614 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 379 insertions(+), 235 deletions(-) diff --git a/info.toml b/info.toml index 9930917c..e3f66e28 100644 --- a/info.toml +++ b/info.toml @@ -5,7 +5,7 @@ name = "intro1" path = "exercises/intro/intro1.rs" mode = "compile" hint = """ -Remove the I AM NOT DONE comment in the exercises/intro/intro1.rs file +Remove the `I AM NOT DONE` comment in the `exercises/intro/intro1.rs` file to move on to the next exercise.""" [[exercises]] @@ -32,21 +32,29 @@ mode = "compile" hint = """ The compiler message is saying that Rust cannot infer the type that the variable binding `x` has with what is given here. -What happens if you annotate the first line in the main function with a type annotation? -What if you give x a value? + +What happens if you annotate the first line in the main function with a type +annotation? + +What if you give `x` a value? + What if you do both? -What type should x be, anyway? -What if x is the same type as 10? What if it's a different type?""" + +What type should `x` be, anyway? + +What if `x` is the same type as `10`? What if it's a different type?""" [[exercises]] name = "variables3" path = "exercises/variables/variables3.rs" mode = "compile" hint = """ -Oops! In this exercise, we have a variable binding that we've created on -in the first line in the main function, and we're trying to use it in the next line, +Oops! In this exercise, we have a variable binding that we've created on in the +first line in the `main` function, and we're trying to use it in the next line, but we haven't given it a value. -We can't print out something that isn't there; try giving x a value! + +We can't print out something that isn't there; try giving `x` a value! + This is an error that can cause bugs that's very easy to make in any programming language -- thankfully the Rust compiler has caught this for us!""" @@ -56,7 +64,7 @@ path = "exercises/variables/variables4.rs" mode = "compile" hint = """ In Rust, variable bindings are immutable by default. But here we're trying -to reassign a different value to x! There's a keyword we can use to make +to reassign a different value to `x`! There's a keyword we can use to make a variable binding mutable instead.""" [[exercises]] @@ -64,14 +72,17 @@ name = "variables5" path = "exercises/variables/variables5.rs" mode = "compile" hint = """ -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 -values to different types like in this exercise. +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 values to different types like in this exercise. + Fortunately Rust has a powerful solution to this problem: 'Shadowing'! -You can read more about 'Shadowing' in the book's section 'Variables and Mutability': +You can read more about 'Shadowing' in the book's section 'Variables and +Mutability': https://doc.rust-lang.org/book/ch03-01-variables-and-mutability.html#shadowing + Try to solve this exercise afterwards using this technique.""" [[exercises]] @@ -81,11 +92,14 @@ mode = "compile" hint = """ We know about variables and mutability, but there is another important type of variable available: constants. -Constants are always immutable and they are declared with keyword 'const' rather -than keyword 'let'. + +Constants are always immutable and they are declared with keyword `const` rather +than keyword `let`. + Constants types must also always be annotated. -Read more about constants and the differences between variables and constants under 'Constants' in the book's section 'Variables and Mutability': +Read more about constants and the differences between variables and constants +under 'Constants' in the book's section 'Variables and Mutability': https://doc.rust-lang.org/book/ch03-01-variables-and-mutability.html#constants """ @@ -116,8 +130,10 @@ mode = "compile" hint = """ This time, the function *declaration* is okay, but there's something wrong with the place where we're calling the function. + As a reminder, you can freely play around with different solutions in Rustlings! -Watch mode will only jump to the next exercise if you remove the I AM NOT DONE comment.""" +Watch mode will only jump to the next exercise if you remove the `I AM NOT +DONE` comment.""" [[exercises]] name = "functions4" @@ -125,10 +141,10 @@ path = "exercises/functions/functions4.rs" mode = "compile" hint = """ The error message points to the function `sale_price` 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! +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 +Also: Did you figure out that, technically, `u32` would be the more fitting type for the prices here, since they can't be negative? If so, kudos!""" [[exercises]] @@ -137,8 +153,13 @@ path = "exercises/functions/functions5.rs" mode = "compile" hint = """ This is a really common error that can be fixed by removing one character. -It happens because Rust distinguishes between expressions and statements: expressions return a value based on their operand(s), and statements simply return a () type which behaves just like `void` in C/C++ language. -We want to return a value of `i32` type from the `square` function, but it is returning a `()` type... +It happens because Rust distinguishes between expressions and statements: +expressions return a value based on their operand(s), and statements simply +return a `()` type which behaves just like `void` in C/C++ language. + +We want to return a value of `i32` type from the `square` function, but it is +returning a `()` type... + They are not the same. There are two solutions: 1. Add a `return` ahead of `num * num;` 2. remove `;`, make it to be `num * num`""" @@ -151,9 +172,11 @@ path = "exercises/if/if1.rs" mode = "test" hint = """ It's possible to do this in one line if you would like! + Some similar examples from other languages: - In C(++) this would be: `a > b ? a : b` - In Python this would be: `a if a > b else b` + Remember in Rust that: - the `if` condition does not need to be surrounded by parentheses - `if`/`else` conditionals are expressions @@ -173,7 +196,8 @@ name = "if3" path = "exercises/if/if3.rs" mode = "test" hint = """ -In Rust, every arm of an `if` expression has to return the same type of value. Make sure the type is consistent across all arms.""" +In Rust, every arm of an `if` expression has to return the same type of value. +Make sure the type is consistent across all arms.""" # QUIZ 1 @@ -204,10 +228,13 @@ mode = "compile" hint = """ There's a shorthand to initialize Arrays with a certain size that does not require you to type in 100 items (but you certainly can if you want!). -For example, you can do: -let array = ["Are we there yet?"; 10]; -Bonus: what are some other things you could have that would return true +For example, you can do: +``` +let array = ["Are we there yet?"; 10]; +``` + +Bonus: what are some other things you could have that would return `true` for `a.len() >= 100`?""" [[exercises]] @@ -215,14 +242,14 @@ name = "primitive_types4" path = "exercises/primitive_types/primitive_types4.rs" mode = "test" hint = """ -Take a look at the Understanding Ownership -> Slices -> Other Slices section of the book: -https://doc.rust-lang.org/book/ch04-03-slices.html -and use the starting and ending (plus one) indices of the items in the Array -that you want to end up in the slice. +Take a look at the 'Understanding Ownership -> Slices -> Other Slices' section +of the book: https://doc.rust-lang.org/book/ch04-03-slices.html and use the +starting and ending (plus one) indices of the items in the `Array` that you +want to end up in the slice. -If you're curious why the first argument of `assert_eq!` does not -have an ampersand for a reference since the second argument is a -reference, take a look at the coercion chapter of the nomicon: +If you're curious why the first argument of `assert_eq!` does not have an +ampersand for a reference since the second argument is areference, take a look +at the coercion chapter of the nomicon: https://doc.rust-lang.org/nomicon/coercions.html""" [[exercises]] @@ -230,9 +257,11 @@ name = "primitive_types5" path = "exercises/primitive_types/primitive_types5.rs" mode = "compile" hint = """ -Take a look at the Data Types -> The Tuple Type section of the book: +Take a look at the 'Data Types -> The Tuple Type' section of the book: https://doc.rust-lang.org/book/ch03-02-data-types.html#the-tuple-type -Particularly the part about destructuring (second to last example in the section). +Particularly the part about destructuring (second to last example in the +section). + You'll need to make a pattern to bind `name` and `age` to the appropriate parts of the tuple. You can do it!!""" @@ -243,7 +272,7 @@ mode = "test" hint = """ While you could use a destructuring `let` for the tuple here, try indexing into it instead, as explained in the last example of the -Data Types -> The Tuple Type section of the book: +'Data Types -> The Tuple Type' section of the book: https://doc.rust-lang.org/book/ch03-02-data-types.html#the-tuple-type Now you have another tool in your toolbox!""" @@ -256,9 +285,10 @@ mode = "test" hint = """ In Rust, there are two ways to define a Vector. 1. One way is to use the `Vec::new()` function to create a new vector - and fill it with the `push()` method. + and fill it with the `push()` method. 2. The second way, which is simpler is to use the `vec![]` macro and - define your elements inside the square brackets. + define your elements inside the square brackets. + Check this chapter: https://doc.rust-lang.org/stable/book/ch08-01-vectors.html of the Rust book to learn more. """ @@ -268,13 +298,19 @@ name = "vecs2" path = "exercises/vecs/vecs2.rs" mode = "test" hint = """ -In the first function we are looping over the Vector and getting a reference to one `element` at a time. -To modify the value of that `element` we need to use the * dereference operator. You can learn more in this chapter of the Rust book: +In the first function we are looping over the Vector and getting a reference to +one `element` at a time. + +To modify the value of that `element` we need to use the `*` dereference +operator. You can learn more in this chapter of the Rust book: https://doc.rust-lang.org/stable/book/ch08-01-vectors.html#iterating-over-the-values-in-a-vector -In the second function this dereferencing is not necessary, because the map function expects the new value to be returned. +In the second function this dereferencing is not necessary, because the `map` +function expects the new value to be returned. + +After you've completed both functions, decide for yourself which approach you +like better. -After you've completed both functions, decide for yourself which approach you like better. What do you think is the more commonly used pattern under Rust developers? """ @@ -285,12 +321,14 @@ name = "move_semantics1" path = "exercises/move_semantics/move_semantics1.rs" mode = "test" hint = """ -So you've got the "cannot borrow immutable local variable `vec` as mutable" error on the line -where we push an element to the vector, right? -The fix for this is going to be adding one keyword, and the addition is NOT on the line where -we push to the vector (where the error is). +So you've got the "cannot borrow immutable local variable `vec` as mutable" +error on the line where we push an element to the vector, right? -Also: Try accessing `vec0` after having called `fill_vec()`. See what happens!""" +The fix for this is going to be adding one keyword, and the addition is NOT on +the line where we push to the vector (where the error is). + +Also: Try accessing `vec0` after having called `fill_vec()`. See what +happens!""" [[exercises]] name = "move_semantics2" @@ -300,14 +338,17 @@ hint = """ When running this exercise for the first time, you'll notice an error about "borrow of moved value". In Rust, when an argument is passed to a function and it's not explicitly returned, you can't use the original variable anymore. -We call this "moving" a variable. When we pass `vec0` into `fill_vec`, it's being -"moved" into `vec1`, meaning we can't access `vec0` anymore after the fact. -Rust provides a couple of different ways to mitigate this issue, feel free to try them all: -1. You could make another, separate version of the data that's in `vec0` and pass that - to `fill_vec` instead. +We call this "moving" a variable. When we pass `vec0` into `fill_vec`, it's +being "moved" into `vec1`, meaning we can't access `vec0` anymore after the +fact. + +Rust provides a couple of different ways to mitigate this issue, feel free to +try them all: +1. You could make another, separate version of the data that's in `vec0` and + pass that to `fill_vec` instead. 2. Make `fill_vec` borrow its argument instead of taking ownership of it, - and then copy the data within the function (`vec.clone()`) in order to return an owned - `Vec`. + and then copy the data within the function (`vec.clone()`) in order to + return an owned `Vec`. """ [[exercises]] @@ -340,9 +381,9 @@ path = "exercises/move_semantics/move_semantics5.rs" mode = "test" hint = """ Carefully reason about the range in which each mutable reference is in -scope. 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': +in the book's section 'References and Borrowing': https://doc.rust-lang.org/book/ch04-02-references-and-borrowing.html#mutable-references. """ @@ -353,10 +394,14 @@ mode = "compile" hint = """ To find the answer, you can consult the book section "References and Borrowing": https://doc.rust-lang.org/stable/book/ch04-02-references-and-borrowing.html -The first problem is that `get_char` is taking ownership of the string. -So `data` is moved and can't be used for `string_uppercase` -`data` is moved to `get_char` first, meaning that `string_uppercase` cannot manipulate the data. -Once you've fixed that, `string_uppercase`'s function signature will also need to be adjusted. + +The first problem is that `get_char` is taking ownership of the string. So +`data` is moved and can't be used for `string_uppercase`. `data` is moved to +`get_char` first, meaning that `string_uppercase` cannot manipulate the data. + +Once you've fixed that, `string_uppercase`'s function signature will also need +to be adjusted. + Can you figure out how? Another hint: it has to do with the `&` character.""" @@ -368,33 +413,46 @@ name = "structs1" path = "exercises/structs/structs1.rs" mode = "test" hint = """ -Rust has more than one type of struct. Three actually, all variants are used to package related data together. -There are normal (or classic) structs. These are named collections of related data stored in fields. +Rust has more than one type of struct. Three actually, all variants are used to +package related data together. + +There are normal (or classic) structs. These are named collections of related +data stored in fields. + Tuple structs are basically just named tuples. -Finally, Unit-like structs. These don't have any fields and are useful for generics. + +Finally, Unit-like structs. These don't have any fields and are useful for +generics. In this exercise you need to complete and implement one of each kind. -Read more about structs in The Book: https://doc.rust-lang.org/book/ch05-01-defining-structs.html""" +Read more about structs in The Book: +https://doc.rust-lang.org/book/ch05-01-defining-structs.html""" [[exercises]] name = "structs2" path = "exercises/structs/structs2.rs" mode = "test" hint = """ -Creating instances of structs is easy, all you need to do is assign some values to its fields. +Creating instances of structs is easy, all you need to do is assign some values +to its fields. + There are however some shortcuts that can be taken when instantiating structs. -Have a look in The Book, to find out more: https://doc.rust-lang.org/stable/book/ch05-01-defining-structs.html#creating-instances-from-other-instances-with-struct-update-syntax""" +Have a look in The Book, to find out more: +https://doc.rust-lang.org/stable/book/ch05-01-defining-structs.html#creating-instances-from-other-instances-with-struct-update-syntax""" [[exercises]] name = "structs3" path = "exercises/structs/structs3.rs" mode = "test" hint = """ -For is_international: What makes a package international? Seems related to the places it goes through right? +For `is_international`: What makes a package international? Seems related to +the places it goes through right? -For get_fees: This method takes an additional argument, is there a field in the Package struct that this relates to? +For `get_fees`: This method takes an additional argument, is there a field in +the `Package` struct that this relates to? -Have a look in The Book, to find out more about method implementations: https://doc.rust-lang.org/book/ch05-03-method-syntax.html""" +Have a look in The Book, to find out more about method implementations: +https://doc.rust-lang.org/book/ch05-03-method-syntax.html""" # ENUMS @@ -418,9 +476,11 @@ path = "exercises/enums/enums3.rs" mode = "test" hint = """ As a first step, you can define enums to compile this code without errors. -and then create a match expression in `process()`. -Note that you need to deconstruct some message variants -in the match expression to get value in the variant.""" + +And then create a match expression in `process()`. + +Note that you need to deconstruct some message variants in the match expression +to get value in the variant.""" # STRINGS @@ -429,34 +489,40 @@ name = "strings1" path = "exercises/strings/strings1.rs" mode = "compile" hint = """ -The `current_favorite_color` function is currently returning a string slice with the `'static` -lifetime. We know this because the data of the string lives in our code itself -- it doesn't -come from a file or user input or another program -- so it will live as long as our program -lives. But it is still a string slice. There's one way to create a `String` by converting a -string slice covered in the Strings chapter of the book, and another way that uses the `From` -trait.""" +The `current_favorite_color` function is currently returning a string slice +with the `'static` lifetime. We know this because the data of the string lives +in our code itself -- it doesn't come from a file or user input or another +program -- so it will live as long as our program lives. + +But it is still a string slice. There's one way to create a `String` by +converting a string slice covered in the Strings chapter of the book, and +another way that uses the `From` trait.""" [[exercises]] name = "strings2" path = "exercises/strings/strings2.rs" mode = "compile" hint = """ -Yes, it would be really easy to fix this by just changing the value bound to `word` to be a -string slice instead of a `String`, wouldn't it?? There is a way to add one character to the -if statement, though, that will coerce the `String` into a string slice. +Yes, it would be really easy to fix this by just changing the value bound to +`word` to be a string slice instead of a `String`, wouldn't it?? There is a way +to add one character to the `if` statement, though, that will coerce the +`String` into a string slice. -Side note: If you're interested in learning about how this kind of reference conversion works, you can jump ahead in the book and read this part in the smart pointers chapter: https://doc.rust-lang.org/stable/book/ch15-02-deref.html#implicit-deref-coercions-with-functions-and-methods""" +Side note: If you're interested in learning about how this kind of reference +conversion works, you can jump ahead in the book and read this part in the +smart pointers chapter: +https://doc.rust-lang.org/stable/book/ch15-02-deref.html#implicit-deref-coercions-with-functions-and-methods""" [[exercises]] name = "strings3" path = "exercises/strings/strings3.rs" mode = "test" hint = """ -There's tons of useful standard library functions for strings. Let's try and use some of -them: ! +There's tons of useful standard library functions for strings. Let's try and use some of them: +https://doc.rust-lang.org/std/string/struct.String.html#method.trim -For the compose_me method: You can either use the `format!` macro, or convert the string -slice into an owned string, which you can then freely extend.""" +For the `compose_me` method: You can either use the `format!` macro, or convert +the string slice into an owned string, which you can then freely extend.""" [[exercises]] name = "strings4" @@ -484,6 +550,7 @@ The delicious_snacks module is trying to present an external interface that is different than its internal structure (the `fruits` and `veggies` modules and associated constants). Complete the `use` statements to fit the uses in main and find the one keyword missing for both constants. + Learn more at https://doc.rust-lang.org/book/ch07-04-bringing-paths-into-scope-with-the-use-keyword.html#re-exporting-names-with-pub-use""" [[exercises]] @@ -491,9 +558,9 @@ name = "modules3" path = "exercises/modules/modules3.rs" mode = "compile" hint = """ -UNIX_EPOCH and SystemTime are declared in the std::time module. Add a use statement -for these two to bring them into scope. You can use nested paths or the glob -operator to bring these two in using only one line.""" +`UNIX_EPOCH` and `SystemTime` are declared in the `std::time` module. Add a +`use` statement for these two to bring them into scope. You can use nested +paths or the glob operator to bring these two in using only one line.""" # HASHMAPS @@ -503,9 +570,10 @@ path = "exercises/hashmaps/hashmaps1.rs" mode = "test" hint = """ Hint 1: Take a look at the return type of the function to figure out - the type for the `basket`. + the type for the `basket`. + Hint 2: Number of fruits should be at least 5. And you have to put - at least three different types of fruits. + at least three different types of fruits. """ [[exercises]] @@ -522,9 +590,14 @@ name = "hashmaps3" path = "exercises/hashmaps/hashmaps3.rs" mode = "test" hint = """ -Hint 1: Use the `entry()` and `or_insert()` methods of `HashMap` to insert entries corresponding to each team in the scores table. +Hint 1: Use the `entry()` and `or_insert()` methods of `HashMap` to insert + entries corresponding to each team in the scores table. + Learn more at https://doc.rust-lang.org/stable/book/ch08-03-hash-maps.html#only-inserting-a-value-if-the-key-has-no-value -Hint 2: If there is already an entry for a given key, the value returned by `entry()` can be updated based on the existing value. + +Hint 2: If there is already an entry for a given key, the value returned by + `entry()` can be updated based on the existing value. + Learn more at https://doc.rust-lang.org/book/ch08-03-hash-maps.html#updating-a-value-based-on-the-old-value """ @@ -543,22 +616,28 @@ name = "options1" path = "exercises/options/options1.rs" mode = "test" hint = """ -Options can have a Some value, with an inner value, or a None value, without an inner value. -There's multiple ways to get at the inner value, you can use unwrap, or pattern match. Unwrapping -is the easiest, but how do you do it safely so that it doesn't panic in your face later?""" +Options can have a `Some` value, with an inner value, or a `None` value, +without an inner value. + +There's multiple ways to get at the inner value, you can use `unwrap`, or +pattern match. Unwrapping is the easiest, but how do you do it safely so that +it doesn't panic in your face later?""" [[exercises]] name = "options2" path = "exercises/options/options2.rs" mode = "test" hint = """ -check out: -https://doc.rust-lang.org/rust-by-example/flow_control/if_let.html -https://doc.rust-lang.org/rust-by-example/flow_control/while_let.html +Check out: -Remember that Options can be stacked in if let and while let. -For example: Some(Some(variable)) = variable2 -Also see Option::flatten +- https://doc.rust-lang.org/rust-by-example/flow_control/if_let.html +- https://doc.rust-lang.org/rust-by-example/flow_control/while_let.html + +Remember that `Option`s can be stacked in `if let` and `while let`. + +For example: `Some(Some(variable)) = variable2` + +Also see `Option::flatten` """ [[exercises]] @@ -566,10 +645,11 @@ name = "options3" path = "exercises/options/options3.rs" mode = "compile" hint = """ -The compiler says a partial move happened in the `match` -statement. How can this be avoided? The compiler shows the correction -needed. After making the correction as suggested by the compiler, do -read: https://doc.rust-lang.org/std/keyword.ref.html""" +The compiler says a partial move happened in the `match` statement. How can +this be avoided? The compiler shows the correction needed. + +After making the correction as suggested by the compiler, do read: +https://doc.rust-lang.org/std/keyword.ref.html""" # ERROR HANDLING @@ -579,16 +659,15 @@ path = "exercises/error_handling/errors1.rs" mode = "test" hint = """ `Ok` and `Err` are one of the variants of `Result`, so what the tests are saying -is that `generate_nametag_text` should return a `Result` instead of an -`Option`. +is that `generate_nametag_text` should return a `Result` instead of an `Option`. To make this change, you'll need to: - - update the return type in the function signature to be a Result that - could be the variants `Ok(String)` and `Err(String)` - - change the body of the function to return `Ok(stuff)` where it currently - returns `Some(stuff)` - - change the body of the function to return `Err(error message)` where it - currently returns `None`""" + - update the return type in the function signature to be a `Result` that could be the variants `Ok(String)` and `Err(String)` + - change the body of the function to return `Ok(stuff)` where it currently + returns `Some(stuff)` + - change the body of the function to return `Err(error message)` where it + currently returns `None`""" [[exercises]] name = "errors2" @@ -597,9 +676,12 @@ mode = "test" hint = """ One way to handle this is using a `match` statement on `item_quantity.parse::()` where the cases are `Ok(something)` and -`Err(something)`. This pattern is very common in Rust, though, so there's -a `?` operator that does pretty much what you would make that match statement -do for you! Take a look at this section of the Error Handling chapter: +`Err(something)`. + +This pattern is very common in Rust, though, so there's a `?` operator that +does pretty much what you would make that match statement do for you! + +Take a look at this section of the 'Error Handling' chapter: https://doc.rust-lang.org/book/ch09-02-recoverable-errors-with-result.html#a-shortcut-for-propagating-errors-the--operator and give it a try!""" @@ -608,32 +690,38 @@ name = "errors3" path = "exercises/error_handling/errors3.rs" mode = "compile" hint = """ -If other functions can return a `Result`, why shouldn't `main`? It's a fairly common -convention to return something like Result<(), ErrorType> from your main function. -The unit (`()`) type is there because nothing is really needed in terms of positive -results.""" +If other functions can return a `Result`, why shouldn't `main`? It's a fairly +common convention to return something like `Result<(), ErrorType>` from your +main function. + +The unit (`()`) type is there because nothing is really needed in terms of +positive results.""" [[exercises]] name = "errors4" path = "exercises/error_handling/errors4.rs" mode = "test" hint = """ -`PositiveNonzeroInteger::new` is always creating a new instance and returning an `Ok` result. -It should be doing some checking, returning an `Err` result if those checks fail, and only -returning an `Ok` result if those checks determine that everything is... okay :)""" +`PositiveNonzeroInteger::new` is always creating a new instance and returning +an `Ok` result. + +It should be doing some checking, returning an `Err` result if those checks +fail, and only returning an `Ok` result if those checks determine that +everything is... okay :)""" [[exercises]] name = "errors5" path = "exercises/error_handling/errors5.rs" mode = "compile" hint = """ -There are two different possible `Result` types produced within `main()`, which are -propagated using `?` operators. How do we declare a return type from `main()` that allows both? +There are two different possible `Result` types produced within `main()`, which +are propagated using `?` operators. How do we declare a return type from +`main()` that allows both? -Under the hood, the `?` operator calls `From::from` on the error value to convert it to a boxed -trait object, a `Box`. This boxed trait object is polymorphic, and since all -errors implement the `error::Error` trait, we can capture lots of different errors in one "Box" -object. +Under the hood, the `?` operator calls `From::from` on the error value to +convert it to a boxed trait object, a `Box`. This boxed trait +object is polymorphic, and since all errors implement the `error::Error` trait, +we can capture lots of different errors in one "Box" object. Check out this section of the book: https://doc.rust-lang.org/book/ch09-02-recoverable-errors-with-result.html#a-shortcut-for-propagating-errors-the--operator @@ -653,7 +741,7 @@ hint = """ This exercise uses a completed version of `PositiveNonzeroInteger` from errors4. -Below the line that TODO asks you to change, there is an example of using +Below the line that `TODO` asks you to change, there is an example of using the `map_err()` method on a `Result` to transform one type of error into another. Try using something similar on the `Result` from `parse()`. You might use the `?` operator to return early from the function, or you might @@ -672,7 +760,9 @@ name = "generics1" path = "exercises/generics/generics1.rs" mode = "compile" hint = """ -Vectors in Rust make use of generics to create dynamically sized arrays of any type. +Vectors in Rust make use of generics to create dynamically sized arrays of any +type. + You need to tell the compiler what type we are pushing onto this vector.""" [[exercises]] @@ -680,7 +770,8 @@ name = "generics2" path = "exercises/generics/generics2.rs" mode = "test" hint = """ -Currently we are wrapping only values of type 'u32'. +Currently we are wrapping only values of type `u32`. + Maybe we could update the explicit references to this data type somehow? If you are still stuck https://doc.rust-lang.org/stable/book/ch10-01-syntax.html#in-method-definitions @@ -702,7 +793,8 @@ name = "traits2" path = "exercises/traits/traits2.rs" mode = "test" hint = """ -Notice how the trait takes ownership of 'self',and returns `Self`. +Notice how the trait takes ownership of `self`, and returns `Self`. + Try mutating the incoming string vector. Have a look at the tests to see what the result should look like! @@ -726,8 +818,8 @@ name = "traits4" path = "exercises/traits/traits4.rs" mode = "test" hint = """ -Instead of using concrete types as parameters you can use traits. Try replacing the -'??' with 'impl ' +Instead of using concrete types as parameters you can use traits. Try replacing +the '??' with 'impl ' See the documentation at: https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters """ @@ -737,8 +829,8 @@ name = "traits5" path = "exercises/traits/traits5.rs" mode = "compile" hint = """ -To ensure a parameter implements multiple traits use the '+ syntax'. Try replacing the -'??' with 'impl <> + <>'. +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 """ @@ -750,8 +842,10 @@ name = "quiz3" 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;`.""" +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;`.""" # LIFETIMES @@ -768,17 +862,22 @@ name = "lifetimes2" path = "exercises/lifetimes/lifetimes2.rs" mode = "compile" hint = """ -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""" +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" path = "exercises/lifetimes/lifetimes3.rs" mode = "compile" hint = """ -If you use a lifetime annotation in a struct's fields, where else does it need to be added?""" +If you use a lifetime annotation in a struct's fields, where else does it need +to be added?""" # TESTS @@ -787,30 +886,39 @@ name = "tests1" path = "exercises/tests/tests1.rs" mode = "test" hint = """ -You don't even need to write any code to test -- you can just test values and run that, even -though you wouldn't do that in real life :) `assert!` is a macro that needs an argument. -Depending on the value of the argument, `assert!` will do nothing (in which case the test will -pass) or `assert!` will panic (in which case the test will fail). So try giving different values -to `assert!` and see which ones compile, which ones pass, and which ones fail :)""" +You don't even need to write any code to test -- you can just test values and +run that, even though you wouldn't do that in real life. :) + +`assert!` is a macro that needs an argument. Depending on the value of the +argument, `assert!` will do nothing (in which case the test will pass) or +`assert!` will panic (in which case the test will fail). + +So try giving different values to `assert!` and see which ones compile, which +ones pass, and which ones fail :)""" [[exercises]] name = "tests2" path = "exercises/tests/tests2.rs" mode = "test" hint = """ -Like the previous exercise, you don't need to write any code to get this test to compile and -run. `assert_eq!` is a macro that takes two arguments and compares them. Try giving it two -values that are equal! Try giving it two arguments that are different! Try giving it two values -that are of different types! Try switching which argument comes first and which comes second!""" +Like the previous exercise, you don't need to write any code to get this test +to compile and run. + +`assert_eq!` is a macro that takes two arguments and compares them. Try giving +it two values that are equal! Try giving it two arguments that are different! +Try giving it two values that are of different types! Try switching which +argument comes first and which comes second!""" [[exercises]] name = "tests3" path = "exercises/tests/tests3.rs" mode = "test" hint = """ -You can call a function right where you're passing arguments to `assert!` -- so you could do -something like `assert!(having_fun())`. If you want to check that you indeed get false, you -can negate the result of what you're doing using `!`, like `assert!(!having_fun())`.""" +You can call a function right where you're passing arguments to `assert!`. So +you could do something like `assert!(having_fun())`. + +If you want to check that you indeed get `false`, you can negate the result of +what you're doing using `!`, like `assert!(!having_fun())`.""" [[exercises]] name = "tests4" @@ -818,7 +926,9 @@ path = "exercises/tests/tests4.rs" mode = "test" hint = """ We expect method `Rectangle::new()` to panic for negative values. + To handle that you need to add a special attribute to the test function. + You can refer to the docs: https://doc.rust-lang.org/stable/book/ch11-01-writing-tests.html#checking-for-panics-with-should_panic""" @@ -830,14 +940,20 @@ path = "exercises/iterators/iterators1.rs" mode = "test" hint = """ Step 1: -We need to apply something to the collection `my_fav_fruits` before we start to go through -it. What could that be? Take a look at the struct definition for a vector for inspiration: + +We need to apply something to the collection `my_fav_fruits` before we start to +go through it. What could that be? Take a look at the struct definition for a +vector for inspiration: https://doc.rust-lang.org/std/vec/struct.Vec.html + Step 2 & step 3: + Very similar to the lines above and below. You've got this! + Step 4: -An iterator goes through all elements in a collection, but what if we've run out of -elements? What should we expect here? If you're stuck, take a look at + +An iterator goes through all elements in a collection, but what if we've run +out of elements? What should we expect here? If you're stuck, take a look at https://doc.rust-lang.org/std/iter/trait.Iterator.html for some ideas. """ @@ -846,50 +962,55 @@ name = "iterators2" path = "exercises/iterators/iterators2.rs" mode = "test" hint = """ -Step 1 +Step 1: + The variable `first` is a `char`. It needs to be capitalized and added to the remaining characters in `c` in order to return the correct `String`. + The remaining characters in `c` can be viewed as a string slice using the `as_str` method. + The documentation for `char` contains many useful methods. https://doc.rust-lang.org/std/primitive.char.html -Step 2 -Create an iterator from the slice. Transform the iterated values by applying -the `capitalize_first` function. Remember to collect the iterator. +Step 2: -Step 3. -This is surprisingly similar to the previous solution. Collect is very powerful -and very general. Rust just needs to know the desired type.""" +Create an iterator from the slice. Transform the iterated values by applying +the `capitalize_first` function. Remember to `collect` the iterator. + +Step 3: + +This is surprisingly similar to the previous solution. `collect` is very +powerful and very general. Rust just needs to know the desired type.""" [[exercises]] name = "iterators3" path = "exercises/iterators/iterators3.rs" mode = "test" hint = """ -The divide function needs to return the correct error when even division is not -possible. +The `divide` function needs to return the correct error when even division is +not possible. -The division_results variable needs to be collected into a collection type. +The `division_results` variable needs to be collected into a collection type. -The result_with_list function needs to return a single Result where the success -case is a vector of integers and the failure case is a DivisionError. +The `result_with_list` function needs to return a single `Result` where the +success case is a vector of integers and the failure case is a `DivisionError`. -The list_of_results function needs to return a vector of results. +The `list_of_results` function needs to return a vector of results. -See https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.collect for how -the `FromIterator` trait is used in `collect()`. This trait is REALLY powerful! It -can make the solution to this exercise infinitely easier.""" +See https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.collect for +how the `FromIterator` trait is used in `collect()`. This trait is REALLY +powerful! It can make the solution to this exercise infinitely easier.""" [[exercises]] name = "iterators4" path = "exercises/iterators/iterators4.rs" mode = "test" hint = """ -In an imperative language, you might write a for loop that updates -a mutable variable. Or, you might write code utilizing recursion -and a match clause. In Rust you can take another functional -approach, computing the factorial elegantly with ranges and iterators. +In an imperative language, you might write a `for` loop that updates a mutable +variable. Or, you might write code utilizing recursion and a match clause. In +Rust you can take another functional approach, computing the factorial +elegantly with ranges and iterators. Hint 2: Check out the `fold` and `rfold` methods!""" @@ -898,16 +1019,17 @@ name = "iterators5" path = "exercises/iterators/iterators5.rs" mode = "test" hint = """ -The documentation for the std::iter::Iterator trait contains numerous methods +The documentation for the `std::iter::Iterator` trait contains numerous methods that would be helpful here. -The collection variable in count_collection_iterator is a slice of HashMaps. It -needs to be converted into an iterator in order to use the iterator methods. +The `collection` variable in `count_collection_iterator` is a slice of +`HashMap`s. It needs to be converted into an iterator in order to use the +iterator methods. -The fold method can be useful in the count_collection_iterator function. +The `fold` method can be useful in the `count_collection_iterator` function. -For a further challenge, consult the documentation for Iterator to find -a different method that could make your code more compact than using fold.""" +For a further challenge, consult the documentation for `Iterator` to find +a different method that could make your code more compact than using `fold`.""" # SMART POINTERS @@ -916,17 +1038,23 @@ name = "box1" path = "exercises/smart_pointers/box1.rs" mode = "test" hint = """ -Step 1 -The compiler's message should help: since we cannot store the value of the actual type -when working with recursive types, we need to store a reference (pointer) to its value. -We should, therefore, place our `List` inside a `Box`. More details in the book here: -https://doc.rust-lang.org/book/ch15-01-box.html#enabling-recursive-types-with-boxes +Step 1: -Step 2 -Creating an empty list should be fairly straightforward (hint: peek at the assertions). -For a non-empty list keep in mind that we want to use our Cons "list builder". -Although the current list is one of integers (i32), feel free to change the definition -and try other types! +The compiler's message should help: since we cannot store the value of the +actual type when working with recursive types, we need to store a reference +(pointer) to its value. + +We should, therefore, place our `List` inside a `Box`. More details in the book +here: https://doc.rust-lang.org/book/ch15-01-box.html#enabling-recursive-types-with-boxes + +Step 2: + +Creating an empty list should be fairly straightforward (hint: peek at the +assertions). + +For a non-empty list keep in mind that we want to use our `Cons` "list builder". +Although the current list is one of integers (`i32`), feel free to change the +definition and try other types! """ [[exercises]] @@ -934,11 +1062,16 @@ name = "rc1" path = "exercises/smart_pointers/rc1.rs" mode = "test" hint = """ -This is a straightforward exercise to use the Rc 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 +This is a straightforward exercise to use the `Rc` 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 `Planet`s 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 :( """ @@ -952,11 +1085,12 @@ Make `shared_numbers` be an `Arc` from the numbers vector. Then, in order to avoid creating a copy of `numbers`, you'll need to create `child_numbers` inside the loop but still in the main thread. -`child_numbers` should be a clone of the Arc of the numbers instead of a +`child_numbers` should be a clone of the `Arc` of the numbers instead of a thread-local copy of the numbers. This is a simple exercise if you understand the underlying concepts, but if this -is too much of a struggle, consider reading through all of Chapter 16 in the book: +is too much of a struggle, consider reading through all of Chapter 16 in the +book: https://doc.rust-lang.org/stable/book/ch16-00-concurrency.html """ @@ -965,7 +1099,8 @@ name = "cow1" path = "exercises/smart_pointers/cow1.rs" mode = "test" hint = """ -If Cow already owns the data it doesn't need to clone it when to_mut() is called. +If `Cow` already owns the data it doesn't need to clone it when `to_mut()` is +called. Check out https://doc.rust-lang.org/std/borrow/enum.Cow.html for documentation on the `Cow` type. @@ -985,7 +1120,9 @@ A challenge with multi-threaded applications is that the main thread can finish before the spawned threads are completed. https://doc.rust-lang.org/book/ch16-01-threads.html#waiting-for-all-threads-to-finish-using-join-handles -Use the JoinHandles to wait for each thread to finish and collect their results. +Use the `JoinHandle`s to wait for each thread to finish and collect their +results. + https://doc.rust-lang.org/std/thread/struct.JoinHandle.html """ @@ -1001,13 +1138,14 @@ mutate the data at a time. Take a look at this section of the book: https://doc.rust-lang.org/book/ch16-03-shared-state.html#atomic-reference-counting-with-arct and keep reading if you'd like more hints :) - Do you now have an `Arc` `Mutex` `JobStatus` at the beginning of main? Like: -`let status = Arc::new(Mutex::new(JobStatus { jobs_completed: 0 }));` -Similar to the code in the example in the book that happens after the text -that says "Sharing a Mutex Between Multiple Threads". If not, give that a try! If you -do and would like more hints, keep reading!! +``` +let status = Arc::new(Mutex::new(JobStatus { jobs_completed: 0 })); +``` +Similar to the code in the example in the book that happens after the text +that says 'Sharing a Mutex Between Multiple Threads'. If not, give that a +try! If you do and would like more hints, keep reading!! Make sure neither of your threads are holding onto the lock of the mutex while they are sleeping, since this will prevent the other thread from @@ -1023,12 +1161,15 @@ name = "threads3" path = "exercises/threads/threads3.rs" mode = "test" 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 receive them in another. -Multiple producers are possible by using clone() to create a duplicate -of the original sending end. +An alternate way to handle concurrency between threads is to use an `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 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. """ @@ -1071,13 +1212,14 @@ path = "exercises/macros/macros4.rs" mode = "compile" hint = """ You only need to add a single character to make this compile. -The way macros are written, it wants to see something between each -"macro arm", so it can separate them. -That's all the macro exercises we have in here, but it's barely even -scratching the surface of what you can do with Rust's macros. For a more -thorough introduction, you can have a read through the little book of Rust -macros: https://veykril.github.io/tlborm/""" +The way macros are written, it wants to see something between each "macro arm", +so it can separate them. + +That's all the macro exercises we have in here, but it's barely even scratching +the surface of what you can do with Rust's macros. For a more thorough +introduction, you can have a read through 'The Little Book of Rust Macros': +https://veykril.github.io/tlborm/""" # CLIPPY @@ -1087,21 +1229,22 @@ path = "exercises/clippy/clippy1.rs" mode = "clippy" hint = """ Rust stores the highest precision version of any long or infinite precision -mathematical constants in the Rust standard library. +mathematical constants in the Rust standard library: https://doc.rust-lang.org/stable/std/f32/consts/index.html -We may be tempted to use our own approximations for certain mathematical constants, -but clippy recognizes those imprecise mathematical constants as a source of -potential error. +We may be tempted to use our own approximations for certain mathematical +constants, but clippy recognizes those imprecise mathematical constants as a +source of potential error. + See the suggestions of the clippy warning in compile output and use the -appropriate replacement constant from std::f32::consts...""" +appropriate replacement constant from `std::f32::consts`...""" [[exercises]] name = "clippy2" path = "exercises/clippy/clippy2.rs" mode = "clippy" hint = """ -`for` loops over Option values are more clearly expressed as an `if let`""" +`for` loops over `Option` values are more clearly expressed as an `if let`""" [[exercises]] name = "clippy3" @@ -1131,8 +1274,8 @@ name = "from_str" path = "exercises/conversions/from_str.rs" mode = "test" hint = """ -The implementation of FromStr should return an Ok with a Person object, -or an Err with an error if the string is not valid. +The implementation of `FromStr` should return an `Ok` with a `Person` object, +or an `Err` with an error if the string is not valid. This is almost like the `from_into` exercise, but returning errors instead of falling back to a default value. @@ -1153,7 +1296,8 @@ path = "exercises/conversions/try_from_into.rs" mode = "test" hint = """ Follow the steps provided right before the `TryFrom` implementation. -You can also use the example at https://doc.rust-lang.org/std/convert/trait.TryFrom.html +You can also use the example at +https://doc.rust-lang.org/std/convert/trait.TryFrom.html Is there an implementation of `TryFrom` in the standard library that can both do the required integer conversion and check the range of the input? @@ -1174,4 +1318,4 @@ name = "as_ref_mut" path = "exercises/conversions/as_ref_mut.rs" mode = "test" hint = """ -Add AsRef or AsMut as a trait bound to the functions.""" +Add `AsRef` or `AsMut` as a trait bound to the functions.""" From b97c88f202b9b9c6f635748198203f2dd5b5cfbe Mon Sep 17 00:00:00 2001 From: liv Date: Fri, 13 Oct 2023 13:28:45 +0200 Subject: [PATCH 17/32] docs: use new fancy install aliases --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8fac7a28..cf001e28 100644 --- a/README.md +++ b/README.md @@ -25,13 +25,13 @@ You will need to have Rust installed. You can get it by visiting Date: Fri, 13 Oct 2023 15:28:14 -0400 Subject: [PATCH 18/32] chore(errors1): fix grammar typo in hint for exercise errors1 This commit corrects a grammar typo in the hint of the errors1 exercise, changing from: "`Ok` and `Err` are one of the variants of `Result`," to: "`Ok` and `Err` are the two variants of `Result`," --- info.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/info.toml b/info.toml index e3f66e28..02599fc5 100644 --- a/info.toml +++ b/info.toml @@ -658,7 +658,7 @@ name = "errors1" path = "exercises/error_handling/errors1.rs" mode = "test" hint = """ -`Ok` and `Err` are one of the variants of `Result`, so what the tests are saying +`Ok` and `Err` are the two variants of `Result`, so what the tests are saying is that `generate_nametag_text` should return a `Result` instead of an `Option`. To make this change, you'll need to: From 642aac6f43f49407308f18306399a910cf8fe6f6 Mon Sep 17 00:00:00 2001 From: Matt Nield <64328730+matthewjnield@users.noreply.github.com> Date: Fri, 13 Oct 2023 15:47:38 -0400 Subject: [PATCH 19/32] chore(errors2): minor description wording change This commit makes a minor change in the wording of the description of the errors2 exercise to avoid potential confusion, changing: "A player of the game will type in how many items they want to buy, and the `total_cost` function will calculate the total cost of the tokens." to "A player of the game will type in how many items they want to buy, and the `total_cost` function will calculate the total cost of the items." --- exercises/error_handling/errors2.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/error_handling/errors2.rs b/exercises/error_handling/errors2.rs index d4a5477b..631fe67f 100644 --- a/exercises/error_handling/errors2.rs +++ b/exercises/error_handling/errors2.rs @@ -3,7 +3,7 @@ // Say we're writing a game where you can buy items with tokens. All items cost // 5 tokens, and whenever you purchase items there is a processing fee of 1 // token. A player of the game will type in how many items they want to buy, and -// the `total_cost` function will calculate the total cost of the tokens. Since +// the `total_cost` function will calculate the total cost of the items. Since // the player typed in the quantity, though, we get it as a string-- and they // might have typed anything, not just numbers! // From c7fccf74c9341fba294dbd895d3e05646d65a558 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Mon, 16 Oct 2023 09:27:25 +0000 Subject: [PATCH 20/32] docs: update AUTHORS.md [skip ci] --- AUTHORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS.md b/AUTHORS.md index 3dcc3e6f..f3807bba 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -347,6 +347,7 @@ authors. Chris Rose
Chris Rose

๐Ÿš‡ d1t2
d1t2

๐Ÿš‡ docwilco
docwilco

๐Ÿ’ป + Matt Nield
Matt Nield

๐Ÿ–‹ From 9a7d88f139e95fb94d42c09ba790afb012f9aad5 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Mon, 16 Oct 2023 09:27:26 +0000 Subject: [PATCH 21/32] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index d31607fd..42f04e49 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -2460,6 +2460,15 @@ "contributions": [ "code" ] + }, + { + "login": "matthewjnield", + "name": "Matt Nield", + "avatar_url": "https://avatars.githubusercontent.com/u/64328730?v=4", + "profile": "https://www.linkedin.com/in/matthew-nield1/", + "contributions": [ + "content" + ] } ], "contributorsPerLine": 8, From 64d95837e9813541cf5b357de13865ce687ae98d Mon Sep 17 00:00:00 2001 From: Adam Brewer Date: Mon, 16 Oct 2023 07:37:12 -0400 Subject: [PATCH 22/32] Update Exercises Directory Names to Reflect Order --- exercises/{intro => 00_intro}/README.md | 0 exercises/{intro => 00_intro}/intro1.rs | 2 +- exercises/{intro => 00_intro}/intro2.rs | 0 .../{variables => 01_variables}/README.md | 0 .../{variables => 01_variables}/variables1.rs | 0 .../{variables => 01_variables}/variables2.rs | 0 .../{variables => 01_variables}/variables3.rs | 0 .../{variables => 01_variables}/variables4.rs | 0 .../{variables => 01_variables}/variables5.rs | 0 .../{variables => 01_variables}/variables6.rs | 0 .../{functions => 02_functions}/README.md | 0 .../{functions => 02_functions}/functions1.rs | 0 .../{functions => 02_functions}/functions2.rs | 0 .../{functions => 02_functions}/functions3.rs | 0 .../{functions => 02_functions}/functions4.rs | 0 .../{functions => 02_functions}/functions5.rs | 0 exercises/{if => 03_if}/README.md | 0 exercises/{if => 03_if}/if1.rs | 0 exercises/{if => 03_if}/if2.rs | 0 exercises/{if => 03_if}/if3.rs | 0 .../README.md | 0 .../primitive_types1.rs | 0 .../primitive_types2.rs | 0 .../primitive_types3.rs | 0 .../primitive_types4.rs | 0 .../primitive_types5.rs | 0 .../primitive_types6.rs | 0 exercises/{vecs => 05_vecs}/README.md | 0 exercises/{vecs => 05_vecs}/vecs1.rs | 0 exercises/{vecs => 05_vecs}/vecs2.rs | 0 .../README.md | 0 .../move_semantics1.rs | 0 .../move_semantics2.rs | 0 .../move_semantics3.rs | 0 .../move_semantics4.rs | 0 .../move_semantics5.rs | 0 .../move_semantics6.rs | 0 exercises/{structs => 07_structs}/README.md | 0 exercises/{structs => 07_structs}/structs1.rs | 0 exercises/{structs => 07_structs}/structs2.rs | 0 exercises/{structs => 07_structs}/structs3.rs | 0 exercises/{enums => 08_enums}/README.md | 0 exercises/{enums => 08_enums}/enums1.rs | 0 exercises/{enums => 08_enums}/enums2.rs | 0 exercises/{enums => 08_enums}/enums3.rs | 0 exercises/{strings => 09_strings}/README.md | 0 exercises/{strings => 09_strings}/strings1.rs | 0 exercises/{strings => 09_strings}/strings2.rs | 0 exercises/{strings => 09_strings}/strings3.rs | 0 exercises/{strings => 09_strings}/strings4.rs | 0 exercises/{modules => 10_modules}/README.md | 0 exercises/{modules => 10_modules}/modules1.rs | 0 exercises/{modules => 10_modules}/modules2.rs | 0 exercises/{modules => 10_modules}/modules3.rs | 0 exercises/{hashmaps => 11_hashmaps}/README.md | 0 .../{hashmaps => 11_hashmaps}/hashmaps1.rs | 0 .../{hashmaps => 11_hashmaps}/hashmaps2.rs | 0 .../{hashmaps => 11_hashmaps}/hashmaps3.rs | 0 exercises/{options => 12_options}/README.md | 0 exercises/{options => 12_options}/options1.rs | 0 exercises/{options => 12_options}/options2.rs | 0 exercises/{options => 12_options}/options3.rs | 0 .../README.md | 0 .../errors1.rs | 0 .../errors2.rs | 0 .../errors3.rs | 0 .../errors4.rs | 0 .../errors5.rs | 0 .../errors6.rs | 0 exercises/{generics => 14_generics}/README.md | 0 .../{generics => 14_generics}/generics1.rs | 0 .../{generics => 14_generics}/generics2.rs | 0 exercises/{traits => 15_traits}/README.md | 0 exercises/{traits => 15_traits}/traits1.rs | 0 exercises/{traits => 15_traits}/traits2.rs | 0 exercises/{traits => 15_traits}/traits3.rs | 0 exercises/{traits => 15_traits}/traits4.rs | 0 exercises/{traits => 15_traits}/traits5.rs | 0 .../{lifetimes => 16_lifetimes}/README.md | 0 .../{lifetimes => 16_lifetimes}/lifetimes1.rs | 0 .../{lifetimes => 16_lifetimes}/lifetimes2.rs | 0 .../{lifetimes => 16_lifetimes}/lifetimes3.rs | 0 exercises/{tests => 17_tests}/README.md | 0 exercises/{tests => 17_tests}/tests1.rs | 0 exercises/{tests => 17_tests}/tests2.rs | 0 exercises/{tests => 17_tests}/tests3.rs | 0 exercises/{tests => 17_tests}/tests4.rs | 0 .../{iterators => 18_iterators}/README.md | 0 .../{iterators => 18_iterators}/iterators1.rs | 0 .../{iterators => 18_iterators}/iterators2.rs | 0 .../{iterators => 18_iterators}/iterators3.rs | 0 .../{iterators => 18_iterators}/iterators4.rs | 0 .../{iterators => 18_iterators}/iterators5.rs | 0 .../README.md | 0 .../arc1.rs | 0 .../box1.rs | 0 .../cow1.rs | 0 .../rc1.rs | 0 exercises/{threads => 20_threads}/README.md | 0 exercises/{threads => 20_threads}/threads1.rs | 0 exercises/{threads => 20_threads}/threads2.rs | 0 exercises/{threads => 20_threads}/threads3.rs | 0 exercises/{macros => 21_macros}/README.md | 0 exercises/{macros => 21_macros}/macros1.rs | 0 exercises/{macros => 21_macros}/macros2.rs | 0 exercises/{macros => 21_macros}/macros3.rs | 0 exercises/{macros => 21_macros}/macros4.rs | 0 exercises/{clippy => 22_clippy}/README.md | 0 exercises/{clippy => 22_clippy}/clippy1.rs | 0 exercises/{clippy => 22_clippy}/clippy2.rs | 0 exercises/{clippy => 22_clippy}/clippy3.rs | 0 .../{conversions => 23_conversions}/README.md | 0 .../as_ref_mut.rs | 0 .../from_into.rs | 0 .../from_str.rs | 0 .../try_from_into.rs | 0 .../using_as.rs | 0 info.toml | 188 +++++++++--------- 118 files changed, 95 insertions(+), 95 deletions(-) rename exercises/{intro => 00_intro}/README.md (100%) rename exercises/{intro => 00_intro}/intro1.rs (98%) rename exercises/{intro => 00_intro}/intro2.rs (100%) rename exercises/{variables => 01_variables}/README.md (100%) rename exercises/{variables => 01_variables}/variables1.rs (100%) rename exercises/{variables => 01_variables}/variables2.rs (100%) rename exercises/{variables => 01_variables}/variables3.rs (100%) rename exercises/{variables => 01_variables}/variables4.rs (100%) rename exercises/{variables => 01_variables}/variables5.rs (100%) rename exercises/{variables => 01_variables}/variables6.rs (100%) rename exercises/{functions => 02_functions}/README.md (100%) rename exercises/{functions => 02_functions}/functions1.rs (100%) rename exercises/{functions => 02_functions}/functions2.rs (100%) rename exercises/{functions => 02_functions}/functions3.rs (100%) rename exercises/{functions => 02_functions}/functions4.rs (100%) rename exercises/{functions => 02_functions}/functions5.rs (100%) rename exercises/{if => 03_if}/README.md (100%) rename exercises/{if => 03_if}/if1.rs (100%) rename exercises/{if => 03_if}/if2.rs (100%) rename exercises/{if => 03_if}/if3.rs (100%) rename exercises/{primitive_types => 04_primitive_types}/README.md (100%) rename exercises/{primitive_types => 04_primitive_types}/primitive_types1.rs (100%) rename exercises/{primitive_types => 04_primitive_types}/primitive_types2.rs (100%) rename exercises/{primitive_types => 04_primitive_types}/primitive_types3.rs (100%) rename exercises/{primitive_types => 04_primitive_types}/primitive_types4.rs (100%) rename exercises/{primitive_types => 04_primitive_types}/primitive_types5.rs (100%) rename exercises/{primitive_types => 04_primitive_types}/primitive_types6.rs (100%) rename exercises/{vecs => 05_vecs}/README.md (100%) rename exercises/{vecs => 05_vecs}/vecs1.rs (100%) rename exercises/{vecs => 05_vecs}/vecs2.rs (100%) rename exercises/{move_semantics => 06_move_semantics}/README.md (100%) rename exercises/{move_semantics => 06_move_semantics}/move_semantics1.rs (100%) rename exercises/{move_semantics => 06_move_semantics}/move_semantics2.rs (100%) rename exercises/{move_semantics => 06_move_semantics}/move_semantics3.rs (100%) rename exercises/{move_semantics => 06_move_semantics}/move_semantics4.rs (100%) rename exercises/{move_semantics => 06_move_semantics}/move_semantics5.rs (100%) rename exercises/{move_semantics => 06_move_semantics}/move_semantics6.rs (100%) rename exercises/{structs => 07_structs}/README.md (100%) rename exercises/{structs => 07_structs}/structs1.rs (100%) rename exercises/{structs => 07_structs}/structs2.rs (100%) rename exercises/{structs => 07_structs}/structs3.rs (100%) rename exercises/{enums => 08_enums}/README.md (100%) rename exercises/{enums => 08_enums}/enums1.rs (100%) rename exercises/{enums => 08_enums}/enums2.rs (100%) rename exercises/{enums => 08_enums}/enums3.rs (100%) rename exercises/{strings => 09_strings}/README.md (100%) rename exercises/{strings => 09_strings}/strings1.rs (100%) rename exercises/{strings => 09_strings}/strings2.rs (100%) rename exercises/{strings => 09_strings}/strings3.rs (100%) rename exercises/{strings => 09_strings}/strings4.rs (100%) rename exercises/{modules => 10_modules}/README.md (100%) rename exercises/{modules => 10_modules}/modules1.rs (100%) rename exercises/{modules => 10_modules}/modules2.rs (100%) rename exercises/{modules => 10_modules}/modules3.rs (100%) rename exercises/{hashmaps => 11_hashmaps}/README.md (100%) rename exercises/{hashmaps => 11_hashmaps}/hashmaps1.rs (100%) rename exercises/{hashmaps => 11_hashmaps}/hashmaps2.rs (100%) rename exercises/{hashmaps => 11_hashmaps}/hashmaps3.rs (100%) rename exercises/{options => 12_options}/README.md (100%) rename exercises/{options => 12_options}/options1.rs (100%) rename exercises/{options => 12_options}/options2.rs (100%) rename exercises/{options => 12_options}/options3.rs (100%) rename exercises/{error_handling => 13_error_handling}/README.md (100%) rename exercises/{error_handling => 13_error_handling}/errors1.rs (100%) rename exercises/{error_handling => 13_error_handling}/errors2.rs (100%) rename exercises/{error_handling => 13_error_handling}/errors3.rs (100%) rename exercises/{error_handling => 13_error_handling}/errors4.rs (100%) rename exercises/{error_handling => 13_error_handling}/errors5.rs (100%) rename exercises/{error_handling => 13_error_handling}/errors6.rs (100%) rename exercises/{generics => 14_generics}/README.md (100%) rename exercises/{generics => 14_generics}/generics1.rs (100%) rename exercises/{generics => 14_generics}/generics2.rs (100%) rename exercises/{traits => 15_traits}/README.md (100%) rename exercises/{traits => 15_traits}/traits1.rs (100%) rename exercises/{traits => 15_traits}/traits2.rs (100%) rename exercises/{traits => 15_traits}/traits3.rs (100%) rename exercises/{traits => 15_traits}/traits4.rs (100%) rename exercises/{traits => 15_traits}/traits5.rs (100%) rename exercises/{lifetimes => 16_lifetimes}/README.md (100%) rename exercises/{lifetimes => 16_lifetimes}/lifetimes1.rs (100%) rename exercises/{lifetimes => 16_lifetimes}/lifetimes2.rs (100%) rename exercises/{lifetimes => 16_lifetimes}/lifetimes3.rs (100%) rename exercises/{tests => 17_tests}/README.md (100%) rename exercises/{tests => 17_tests}/tests1.rs (100%) rename exercises/{tests => 17_tests}/tests2.rs (100%) rename exercises/{tests => 17_tests}/tests3.rs (100%) rename exercises/{tests => 17_tests}/tests4.rs (100%) rename exercises/{iterators => 18_iterators}/README.md (100%) rename exercises/{iterators => 18_iterators}/iterators1.rs (100%) rename exercises/{iterators => 18_iterators}/iterators2.rs (100%) rename exercises/{iterators => 18_iterators}/iterators3.rs (100%) rename exercises/{iterators => 18_iterators}/iterators4.rs (100%) rename exercises/{iterators => 18_iterators}/iterators5.rs (100%) rename exercises/{smart_pointers => 19_smart_pointers}/README.md (100%) rename exercises/{smart_pointers => 19_smart_pointers}/arc1.rs (100%) rename exercises/{smart_pointers => 19_smart_pointers}/box1.rs (100%) rename exercises/{smart_pointers => 19_smart_pointers}/cow1.rs (100%) rename exercises/{smart_pointers => 19_smart_pointers}/rc1.rs (100%) rename exercises/{threads => 20_threads}/README.md (100%) rename exercises/{threads => 20_threads}/threads1.rs (100%) rename exercises/{threads => 20_threads}/threads2.rs (100%) rename exercises/{threads => 20_threads}/threads3.rs (100%) rename exercises/{macros => 21_macros}/README.md (100%) rename exercises/{macros => 21_macros}/macros1.rs (100%) rename exercises/{macros => 21_macros}/macros2.rs (100%) rename exercises/{macros => 21_macros}/macros3.rs (100%) rename exercises/{macros => 21_macros}/macros4.rs (100%) rename exercises/{clippy => 22_clippy}/README.md (100%) rename exercises/{clippy => 22_clippy}/clippy1.rs (100%) rename exercises/{clippy => 22_clippy}/clippy2.rs (100%) rename exercises/{clippy => 22_clippy}/clippy3.rs (100%) rename exercises/{conversions => 23_conversions}/README.md (100%) rename exercises/{conversions => 23_conversions}/as_ref_mut.rs (100%) rename exercises/{conversions => 23_conversions}/from_into.rs (100%) rename exercises/{conversions => 23_conversions}/from_str.rs (100%) rename exercises/{conversions => 23_conversions}/try_from_into.rs (100%) rename exercises/{conversions => 23_conversions}/using_as.rs (100%) diff --git a/exercises/intro/README.md b/exercises/00_intro/README.md similarity index 100% rename from exercises/intro/README.md rename to exercises/00_intro/README.md diff --git a/exercises/intro/intro1.rs b/exercises/00_intro/intro1.rs similarity index 98% rename from exercises/intro/intro1.rs rename to exercises/00_intro/intro1.rs index 37fa0112..c5196d62 100644 --- a/exercises/intro/intro1.rs +++ b/exercises/00_intro/intro1.rs @@ -29,7 +29,7 @@ fn main() { println!("or logic error. The central concept behind Rustlings is to fix these errors and"); println!("solve the exercises. Good luck!"); println!(); - println!("The source for this exercise is in `exercises/intro/intro1.rs`. Have a look!"); + println!("The source for this exercise is in `exercises/intro00/intro1.rs`. Have a look!"); println!( "Going forward, the source of the exercises will always be in the success/failure output." ); diff --git a/exercises/intro/intro2.rs b/exercises/00_intro/intro2.rs similarity index 100% rename from exercises/intro/intro2.rs rename to exercises/00_intro/intro2.rs diff --git a/exercises/variables/README.md b/exercises/01_variables/README.md similarity index 100% rename from exercises/variables/README.md rename to exercises/01_variables/README.md diff --git a/exercises/variables/variables1.rs b/exercises/01_variables/variables1.rs similarity index 100% rename from exercises/variables/variables1.rs rename to exercises/01_variables/variables1.rs diff --git a/exercises/variables/variables2.rs b/exercises/01_variables/variables2.rs similarity index 100% rename from exercises/variables/variables2.rs rename to exercises/01_variables/variables2.rs diff --git a/exercises/variables/variables3.rs b/exercises/01_variables/variables3.rs similarity index 100% rename from exercises/variables/variables3.rs rename to exercises/01_variables/variables3.rs diff --git a/exercises/variables/variables4.rs b/exercises/01_variables/variables4.rs similarity index 100% rename from exercises/variables/variables4.rs rename to exercises/01_variables/variables4.rs diff --git a/exercises/variables/variables5.rs b/exercises/01_variables/variables5.rs similarity index 100% rename from exercises/variables/variables5.rs rename to exercises/01_variables/variables5.rs diff --git a/exercises/variables/variables6.rs b/exercises/01_variables/variables6.rs similarity index 100% rename from exercises/variables/variables6.rs rename to exercises/01_variables/variables6.rs diff --git a/exercises/functions/README.md b/exercises/02_functions/README.md similarity index 100% rename from exercises/functions/README.md rename to exercises/02_functions/README.md diff --git a/exercises/functions/functions1.rs b/exercises/02_functions/functions1.rs similarity index 100% rename from exercises/functions/functions1.rs rename to exercises/02_functions/functions1.rs diff --git a/exercises/functions/functions2.rs b/exercises/02_functions/functions2.rs similarity index 100% rename from exercises/functions/functions2.rs rename to exercises/02_functions/functions2.rs diff --git a/exercises/functions/functions3.rs b/exercises/02_functions/functions3.rs similarity index 100% rename from exercises/functions/functions3.rs rename to exercises/02_functions/functions3.rs diff --git a/exercises/functions/functions4.rs b/exercises/02_functions/functions4.rs similarity index 100% rename from exercises/functions/functions4.rs rename to exercises/02_functions/functions4.rs diff --git a/exercises/functions/functions5.rs b/exercises/02_functions/functions5.rs similarity index 100% rename from exercises/functions/functions5.rs rename to exercises/02_functions/functions5.rs diff --git a/exercises/if/README.md b/exercises/03_if/README.md similarity index 100% rename from exercises/if/README.md rename to exercises/03_if/README.md diff --git a/exercises/if/if1.rs b/exercises/03_if/if1.rs similarity index 100% rename from exercises/if/if1.rs rename to exercises/03_if/if1.rs diff --git a/exercises/if/if2.rs b/exercises/03_if/if2.rs similarity index 100% rename from exercises/if/if2.rs rename to exercises/03_if/if2.rs diff --git a/exercises/if/if3.rs b/exercises/03_if/if3.rs similarity index 100% rename from exercises/if/if3.rs rename to exercises/03_if/if3.rs diff --git a/exercises/primitive_types/README.md b/exercises/04_primitive_types/README.md similarity index 100% rename from exercises/primitive_types/README.md rename to exercises/04_primitive_types/README.md diff --git a/exercises/primitive_types/primitive_types1.rs b/exercises/04_primitive_types/primitive_types1.rs similarity index 100% rename from exercises/primitive_types/primitive_types1.rs rename to exercises/04_primitive_types/primitive_types1.rs diff --git a/exercises/primitive_types/primitive_types2.rs b/exercises/04_primitive_types/primitive_types2.rs similarity index 100% rename from exercises/primitive_types/primitive_types2.rs rename to exercises/04_primitive_types/primitive_types2.rs diff --git a/exercises/primitive_types/primitive_types3.rs b/exercises/04_primitive_types/primitive_types3.rs similarity index 100% rename from exercises/primitive_types/primitive_types3.rs rename to exercises/04_primitive_types/primitive_types3.rs diff --git a/exercises/primitive_types/primitive_types4.rs b/exercises/04_primitive_types/primitive_types4.rs similarity index 100% rename from exercises/primitive_types/primitive_types4.rs rename to exercises/04_primitive_types/primitive_types4.rs diff --git a/exercises/primitive_types/primitive_types5.rs b/exercises/04_primitive_types/primitive_types5.rs similarity index 100% rename from exercises/primitive_types/primitive_types5.rs rename to exercises/04_primitive_types/primitive_types5.rs diff --git a/exercises/primitive_types/primitive_types6.rs b/exercises/04_primitive_types/primitive_types6.rs similarity index 100% rename from exercises/primitive_types/primitive_types6.rs rename to exercises/04_primitive_types/primitive_types6.rs diff --git a/exercises/vecs/README.md b/exercises/05_vecs/README.md similarity index 100% rename from exercises/vecs/README.md rename to exercises/05_vecs/README.md diff --git a/exercises/vecs/vecs1.rs b/exercises/05_vecs/vecs1.rs similarity index 100% rename from exercises/vecs/vecs1.rs rename to exercises/05_vecs/vecs1.rs diff --git a/exercises/vecs/vecs2.rs b/exercises/05_vecs/vecs2.rs similarity index 100% rename from exercises/vecs/vecs2.rs rename to exercises/05_vecs/vecs2.rs diff --git a/exercises/move_semantics/README.md b/exercises/06_move_semantics/README.md similarity index 100% rename from exercises/move_semantics/README.md rename to exercises/06_move_semantics/README.md diff --git a/exercises/move_semantics/move_semantics1.rs b/exercises/06_move_semantics/move_semantics1.rs similarity index 100% rename from exercises/move_semantics/move_semantics1.rs rename to exercises/06_move_semantics/move_semantics1.rs diff --git a/exercises/move_semantics/move_semantics2.rs b/exercises/06_move_semantics/move_semantics2.rs similarity index 100% rename from exercises/move_semantics/move_semantics2.rs rename to exercises/06_move_semantics/move_semantics2.rs diff --git a/exercises/move_semantics/move_semantics3.rs b/exercises/06_move_semantics/move_semantics3.rs similarity index 100% rename from exercises/move_semantics/move_semantics3.rs rename to exercises/06_move_semantics/move_semantics3.rs diff --git a/exercises/move_semantics/move_semantics4.rs b/exercises/06_move_semantics/move_semantics4.rs similarity index 100% rename from exercises/move_semantics/move_semantics4.rs rename to exercises/06_move_semantics/move_semantics4.rs diff --git a/exercises/move_semantics/move_semantics5.rs b/exercises/06_move_semantics/move_semantics5.rs similarity index 100% rename from exercises/move_semantics/move_semantics5.rs rename to exercises/06_move_semantics/move_semantics5.rs diff --git a/exercises/move_semantics/move_semantics6.rs b/exercises/06_move_semantics/move_semantics6.rs similarity index 100% rename from exercises/move_semantics/move_semantics6.rs rename to exercises/06_move_semantics/move_semantics6.rs diff --git a/exercises/structs/README.md b/exercises/07_structs/README.md similarity index 100% rename from exercises/structs/README.md rename to exercises/07_structs/README.md diff --git a/exercises/structs/structs1.rs b/exercises/07_structs/structs1.rs similarity index 100% rename from exercises/structs/structs1.rs rename to exercises/07_structs/structs1.rs diff --git a/exercises/structs/structs2.rs b/exercises/07_structs/structs2.rs similarity index 100% rename from exercises/structs/structs2.rs rename to exercises/07_structs/structs2.rs diff --git a/exercises/structs/structs3.rs b/exercises/07_structs/structs3.rs similarity index 100% rename from exercises/structs/structs3.rs rename to exercises/07_structs/structs3.rs diff --git a/exercises/enums/README.md b/exercises/08_enums/README.md similarity index 100% rename from exercises/enums/README.md rename to exercises/08_enums/README.md diff --git a/exercises/enums/enums1.rs b/exercises/08_enums/enums1.rs similarity index 100% rename from exercises/enums/enums1.rs rename to exercises/08_enums/enums1.rs diff --git a/exercises/enums/enums2.rs b/exercises/08_enums/enums2.rs similarity index 100% rename from exercises/enums/enums2.rs rename to exercises/08_enums/enums2.rs diff --git a/exercises/enums/enums3.rs b/exercises/08_enums/enums3.rs similarity index 100% rename from exercises/enums/enums3.rs rename to exercises/08_enums/enums3.rs diff --git a/exercises/strings/README.md b/exercises/09_strings/README.md similarity index 100% rename from exercises/strings/README.md rename to exercises/09_strings/README.md diff --git a/exercises/strings/strings1.rs b/exercises/09_strings/strings1.rs similarity index 100% rename from exercises/strings/strings1.rs rename to exercises/09_strings/strings1.rs diff --git a/exercises/strings/strings2.rs b/exercises/09_strings/strings2.rs similarity index 100% rename from exercises/strings/strings2.rs rename to exercises/09_strings/strings2.rs diff --git a/exercises/strings/strings3.rs b/exercises/09_strings/strings3.rs similarity index 100% rename from exercises/strings/strings3.rs rename to exercises/09_strings/strings3.rs diff --git a/exercises/strings/strings4.rs b/exercises/09_strings/strings4.rs similarity index 100% rename from exercises/strings/strings4.rs rename to exercises/09_strings/strings4.rs diff --git a/exercises/modules/README.md b/exercises/10_modules/README.md similarity index 100% rename from exercises/modules/README.md rename to exercises/10_modules/README.md diff --git a/exercises/modules/modules1.rs b/exercises/10_modules/modules1.rs similarity index 100% rename from exercises/modules/modules1.rs rename to exercises/10_modules/modules1.rs diff --git a/exercises/modules/modules2.rs b/exercises/10_modules/modules2.rs similarity index 100% rename from exercises/modules/modules2.rs rename to exercises/10_modules/modules2.rs diff --git a/exercises/modules/modules3.rs b/exercises/10_modules/modules3.rs similarity index 100% rename from exercises/modules/modules3.rs rename to exercises/10_modules/modules3.rs diff --git a/exercises/hashmaps/README.md b/exercises/11_hashmaps/README.md similarity index 100% rename from exercises/hashmaps/README.md rename to exercises/11_hashmaps/README.md diff --git a/exercises/hashmaps/hashmaps1.rs b/exercises/11_hashmaps/hashmaps1.rs similarity index 100% rename from exercises/hashmaps/hashmaps1.rs rename to exercises/11_hashmaps/hashmaps1.rs diff --git a/exercises/hashmaps/hashmaps2.rs b/exercises/11_hashmaps/hashmaps2.rs similarity index 100% rename from exercises/hashmaps/hashmaps2.rs rename to exercises/11_hashmaps/hashmaps2.rs diff --git a/exercises/hashmaps/hashmaps3.rs b/exercises/11_hashmaps/hashmaps3.rs similarity index 100% rename from exercises/hashmaps/hashmaps3.rs rename to exercises/11_hashmaps/hashmaps3.rs diff --git a/exercises/options/README.md b/exercises/12_options/README.md similarity index 100% rename from exercises/options/README.md rename to exercises/12_options/README.md diff --git a/exercises/options/options1.rs b/exercises/12_options/options1.rs similarity index 100% rename from exercises/options/options1.rs rename to exercises/12_options/options1.rs diff --git a/exercises/options/options2.rs b/exercises/12_options/options2.rs similarity index 100% rename from exercises/options/options2.rs rename to exercises/12_options/options2.rs diff --git a/exercises/options/options3.rs b/exercises/12_options/options3.rs similarity index 100% rename from exercises/options/options3.rs rename to exercises/12_options/options3.rs diff --git a/exercises/error_handling/README.md b/exercises/13_error_handling/README.md similarity index 100% rename from exercises/error_handling/README.md rename to exercises/13_error_handling/README.md diff --git a/exercises/error_handling/errors1.rs b/exercises/13_error_handling/errors1.rs similarity index 100% rename from exercises/error_handling/errors1.rs rename to exercises/13_error_handling/errors1.rs diff --git a/exercises/error_handling/errors2.rs b/exercises/13_error_handling/errors2.rs similarity index 100% rename from exercises/error_handling/errors2.rs rename to exercises/13_error_handling/errors2.rs diff --git a/exercises/error_handling/errors3.rs b/exercises/13_error_handling/errors3.rs similarity index 100% rename from exercises/error_handling/errors3.rs rename to exercises/13_error_handling/errors3.rs diff --git a/exercises/error_handling/errors4.rs b/exercises/13_error_handling/errors4.rs similarity index 100% rename from exercises/error_handling/errors4.rs rename to exercises/13_error_handling/errors4.rs diff --git a/exercises/error_handling/errors5.rs b/exercises/13_error_handling/errors5.rs similarity index 100% rename from exercises/error_handling/errors5.rs rename to exercises/13_error_handling/errors5.rs diff --git a/exercises/error_handling/errors6.rs b/exercises/13_error_handling/errors6.rs similarity index 100% rename from exercises/error_handling/errors6.rs rename to exercises/13_error_handling/errors6.rs diff --git a/exercises/generics/README.md b/exercises/14_generics/README.md similarity index 100% rename from exercises/generics/README.md rename to exercises/14_generics/README.md diff --git a/exercises/generics/generics1.rs b/exercises/14_generics/generics1.rs similarity index 100% rename from exercises/generics/generics1.rs rename to exercises/14_generics/generics1.rs diff --git a/exercises/generics/generics2.rs b/exercises/14_generics/generics2.rs similarity index 100% rename from exercises/generics/generics2.rs rename to exercises/14_generics/generics2.rs diff --git a/exercises/traits/README.md b/exercises/15_traits/README.md similarity index 100% rename from exercises/traits/README.md rename to exercises/15_traits/README.md diff --git a/exercises/traits/traits1.rs b/exercises/15_traits/traits1.rs similarity index 100% rename from exercises/traits/traits1.rs rename to exercises/15_traits/traits1.rs diff --git a/exercises/traits/traits2.rs b/exercises/15_traits/traits2.rs similarity index 100% rename from exercises/traits/traits2.rs rename to exercises/15_traits/traits2.rs diff --git a/exercises/traits/traits3.rs b/exercises/15_traits/traits3.rs similarity index 100% rename from exercises/traits/traits3.rs rename to exercises/15_traits/traits3.rs diff --git a/exercises/traits/traits4.rs b/exercises/15_traits/traits4.rs similarity index 100% rename from exercises/traits/traits4.rs rename to exercises/15_traits/traits4.rs diff --git a/exercises/traits/traits5.rs b/exercises/15_traits/traits5.rs similarity index 100% rename from exercises/traits/traits5.rs rename to exercises/15_traits/traits5.rs diff --git a/exercises/lifetimes/README.md b/exercises/16_lifetimes/README.md similarity index 100% rename from exercises/lifetimes/README.md rename to exercises/16_lifetimes/README.md diff --git a/exercises/lifetimes/lifetimes1.rs b/exercises/16_lifetimes/lifetimes1.rs similarity index 100% rename from exercises/lifetimes/lifetimes1.rs rename to exercises/16_lifetimes/lifetimes1.rs diff --git a/exercises/lifetimes/lifetimes2.rs b/exercises/16_lifetimes/lifetimes2.rs similarity index 100% rename from exercises/lifetimes/lifetimes2.rs rename to exercises/16_lifetimes/lifetimes2.rs diff --git a/exercises/lifetimes/lifetimes3.rs b/exercises/16_lifetimes/lifetimes3.rs similarity index 100% rename from exercises/lifetimes/lifetimes3.rs rename to exercises/16_lifetimes/lifetimes3.rs diff --git a/exercises/tests/README.md b/exercises/17_tests/README.md similarity index 100% rename from exercises/tests/README.md rename to exercises/17_tests/README.md diff --git a/exercises/tests/tests1.rs b/exercises/17_tests/tests1.rs similarity index 100% rename from exercises/tests/tests1.rs rename to exercises/17_tests/tests1.rs diff --git a/exercises/tests/tests2.rs b/exercises/17_tests/tests2.rs similarity index 100% rename from exercises/tests/tests2.rs rename to exercises/17_tests/tests2.rs diff --git a/exercises/tests/tests3.rs b/exercises/17_tests/tests3.rs similarity index 100% rename from exercises/tests/tests3.rs rename to exercises/17_tests/tests3.rs diff --git a/exercises/tests/tests4.rs b/exercises/17_tests/tests4.rs similarity index 100% rename from exercises/tests/tests4.rs rename to exercises/17_tests/tests4.rs diff --git a/exercises/iterators/README.md b/exercises/18_iterators/README.md similarity index 100% rename from exercises/iterators/README.md rename to exercises/18_iterators/README.md diff --git a/exercises/iterators/iterators1.rs b/exercises/18_iterators/iterators1.rs similarity index 100% rename from exercises/iterators/iterators1.rs rename to exercises/18_iterators/iterators1.rs diff --git a/exercises/iterators/iterators2.rs b/exercises/18_iterators/iterators2.rs similarity index 100% rename from exercises/iterators/iterators2.rs rename to exercises/18_iterators/iterators2.rs diff --git a/exercises/iterators/iterators3.rs b/exercises/18_iterators/iterators3.rs similarity index 100% rename from exercises/iterators/iterators3.rs rename to exercises/18_iterators/iterators3.rs diff --git a/exercises/iterators/iterators4.rs b/exercises/18_iterators/iterators4.rs similarity index 100% rename from exercises/iterators/iterators4.rs rename to exercises/18_iterators/iterators4.rs diff --git a/exercises/iterators/iterators5.rs b/exercises/18_iterators/iterators5.rs similarity index 100% rename from exercises/iterators/iterators5.rs rename to exercises/18_iterators/iterators5.rs diff --git a/exercises/smart_pointers/README.md b/exercises/19_smart_pointers/README.md similarity index 100% rename from exercises/smart_pointers/README.md rename to exercises/19_smart_pointers/README.md diff --git a/exercises/smart_pointers/arc1.rs b/exercises/19_smart_pointers/arc1.rs similarity index 100% rename from exercises/smart_pointers/arc1.rs rename to exercises/19_smart_pointers/arc1.rs diff --git a/exercises/smart_pointers/box1.rs b/exercises/19_smart_pointers/box1.rs similarity index 100% rename from exercises/smart_pointers/box1.rs rename to exercises/19_smart_pointers/box1.rs diff --git a/exercises/smart_pointers/cow1.rs b/exercises/19_smart_pointers/cow1.rs similarity index 100% rename from exercises/smart_pointers/cow1.rs rename to exercises/19_smart_pointers/cow1.rs diff --git a/exercises/smart_pointers/rc1.rs b/exercises/19_smart_pointers/rc1.rs similarity index 100% rename from exercises/smart_pointers/rc1.rs rename to exercises/19_smart_pointers/rc1.rs diff --git a/exercises/threads/README.md b/exercises/20_threads/README.md similarity index 100% rename from exercises/threads/README.md rename to exercises/20_threads/README.md diff --git a/exercises/threads/threads1.rs b/exercises/20_threads/threads1.rs similarity index 100% rename from exercises/threads/threads1.rs rename to exercises/20_threads/threads1.rs diff --git a/exercises/threads/threads2.rs b/exercises/20_threads/threads2.rs similarity index 100% rename from exercises/threads/threads2.rs rename to exercises/20_threads/threads2.rs diff --git a/exercises/threads/threads3.rs b/exercises/20_threads/threads3.rs similarity index 100% rename from exercises/threads/threads3.rs rename to exercises/20_threads/threads3.rs diff --git a/exercises/macros/README.md b/exercises/21_macros/README.md similarity index 100% rename from exercises/macros/README.md rename to exercises/21_macros/README.md diff --git a/exercises/macros/macros1.rs b/exercises/21_macros/macros1.rs similarity index 100% rename from exercises/macros/macros1.rs rename to exercises/21_macros/macros1.rs diff --git a/exercises/macros/macros2.rs b/exercises/21_macros/macros2.rs similarity index 100% rename from exercises/macros/macros2.rs rename to exercises/21_macros/macros2.rs diff --git a/exercises/macros/macros3.rs b/exercises/21_macros/macros3.rs similarity index 100% rename from exercises/macros/macros3.rs rename to exercises/21_macros/macros3.rs diff --git a/exercises/macros/macros4.rs b/exercises/21_macros/macros4.rs similarity index 100% rename from exercises/macros/macros4.rs rename to exercises/21_macros/macros4.rs diff --git a/exercises/clippy/README.md b/exercises/22_clippy/README.md similarity index 100% rename from exercises/clippy/README.md rename to exercises/22_clippy/README.md diff --git a/exercises/clippy/clippy1.rs b/exercises/22_clippy/clippy1.rs similarity index 100% rename from exercises/clippy/clippy1.rs rename to exercises/22_clippy/clippy1.rs diff --git a/exercises/clippy/clippy2.rs b/exercises/22_clippy/clippy2.rs similarity index 100% rename from exercises/clippy/clippy2.rs rename to exercises/22_clippy/clippy2.rs diff --git a/exercises/clippy/clippy3.rs b/exercises/22_clippy/clippy3.rs similarity index 100% rename from exercises/clippy/clippy3.rs rename to exercises/22_clippy/clippy3.rs diff --git a/exercises/conversions/README.md b/exercises/23_conversions/README.md similarity index 100% rename from exercises/conversions/README.md rename to exercises/23_conversions/README.md diff --git a/exercises/conversions/as_ref_mut.rs b/exercises/23_conversions/as_ref_mut.rs similarity index 100% rename from exercises/conversions/as_ref_mut.rs rename to exercises/23_conversions/as_ref_mut.rs diff --git a/exercises/conversions/from_into.rs b/exercises/23_conversions/from_into.rs similarity index 100% rename from exercises/conversions/from_into.rs rename to exercises/23_conversions/from_into.rs diff --git a/exercises/conversions/from_str.rs b/exercises/23_conversions/from_str.rs similarity index 100% rename from exercises/conversions/from_str.rs rename to exercises/23_conversions/from_str.rs diff --git a/exercises/conversions/try_from_into.rs b/exercises/23_conversions/try_from_into.rs similarity index 100% rename from exercises/conversions/try_from_into.rs rename to exercises/23_conversions/try_from_into.rs diff --git a/exercises/conversions/using_as.rs b/exercises/23_conversions/using_as.rs similarity index 100% rename from exercises/conversions/using_as.rs rename to exercises/23_conversions/using_as.rs diff --git a/info.toml b/info.toml index 02599fc5..bbfee142 100644 --- a/info.toml +++ b/info.toml @@ -2,15 +2,15 @@ [[exercises]] name = "intro1" -path = "exercises/intro/intro1.rs" +path = "exercises/00_intro/intro1.rs" mode = "compile" hint = """ -Remove the `I AM NOT DONE` comment in the `exercises/intro/intro1.rs` file +Remove the `I AM NOT DONE` comment in the `exercises/intro00/intro1.rs` file to move on to the next exercise.""" [[exercises]] name = "intro2" -path = "exercises/intro/intro2.rs" +path = "exercises/00_intro/intro2.rs" mode = "compile" hint = """ Add an argument after the format string.""" @@ -19,7 +19,7 @@ Add an argument after the format string.""" [[exercises]] name = "variables1" -path = "exercises/variables/variables1.rs" +path = "exercises/01_variables/variables1.rs" mode = "compile" hint = """ The declaration in the first line in the main function is missing a keyword @@ -27,7 +27,7 @@ that is needed in Rust to create a new variable binding.""" [[exercises]] name = "variables2" -path = "exercises/variables/variables2.rs" +path = "exercises/01_variables/variables2.rs" mode = "compile" hint = """ The compiler message is saying that Rust cannot infer the type that the @@ -46,7 +46,7 @@ What if `x` is the same type as `10`? What if it's a different type?""" [[exercises]] name = "variables3" -path = "exercises/variables/variables3.rs" +path = "exercises/01_variables/variables3.rs" mode = "compile" hint = """ Oops! In this exercise, we have a variable binding that we've created on in the @@ -60,7 +60,7 @@ programming language -- thankfully the Rust compiler has caught this for us!""" [[exercises]] name = "variables4" -path = "exercises/variables/variables4.rs" +path = "exercises/01_variables/variables4.rs" mode = "compile" hint = """ In Rust, variable bindings are immutable by default. But here we're trying @@ -69,7 +69,7 @@ a variable binding mutable instead.""" [[exercises]] name = "variables5" -path = "exercises/variables/variables5.rs" +path = "exercises/01_variables/variables5.rs" mode = "compile" hint = """ In `variables4` we already learned how to make an immutable variable mutable @@ -87,7 +87,7 @@ Try to solve this exercise afterwards using this technique.""" [[exercises]] name = "variables6" -path = "exercises/variables/variables6.rs" +path = "exercises/01_variables/variables6.rs" mode = "compile" hint = """ We know about variables and mutability, but there is another important type of @@ -107,7 +107,7 @@ https://doc.rust-lang.org/book/ch03-01-variables-and-mutability.html#constants [[exercises]] name = "functions1" -path = "exercises/functions/functions1.rs" +path = "exercises/02_functions/functions1.rs" mode = "compile" hint = """ This main function is calling a function that it expects to exist, but the @@ -117,7 +117,7 @@ Sounds a lot like `main`, doesn't it?""" [[exercises]] name = "functions2" -path = "exercises/functions/functions2.rs" +path = "exercises/02_functions/functions2.rs" mode = "compile" hint = """ Rust requires that all parts of a function's signature have type annotations, @@ -125,7 +125,7 @@ but `call_me` is missing the type annotation of `num`.""" [[exercises]] name = "functions3" -path = "exercises/functions/functions3.rs" +path = "exercises/02_functions/functions3.rs" mode = "compile" hint = """ This time, the function *declaration* is okay, but there's something wrong @@ -137,7 +137,7 @@ DONE` comment.""" [[exercises]] name = "functions4" -path = "exercises/functions/functions4.rs" +path = "exercises/02_functions/functions4.rs" mode = "compile" hint = """ The error message points to the function `sale_price` and says it expects a type @@ -149,7 +149,7 @@ for the prices here, since they can't be negative? If so, kudos!""" [[exercises]] name = "functions5" -path = "exercises/functions/functions5.rs" +path = "exercises/02_functions/functions5.rs" mode = "compile" hint = """ This is a really common error that can be fixed by removing one character. @@ -168,7 +168,7 @@ They are not the same. There are two solutions: [[exercises]] name = "if1" -path = "exercises/if/if1.rs" +path = "exercises/03_if/if1.rs" mode = "test" hint = """ It's possible to do this in one line if you would like! @@ -184,7 +184,7 @@ Remember in Rust that: [[exercises]] name = "if2" -path = "exercises/if/if2.rs" +path = "exercises/03_if/if2.rs" mode = "test" hint = """ For that first compiler error, it's important in Rust that each conditional @@ -193,7 +193,7 @@ conditions checking different input values.""" [[exercises]] name = "if3" -path = "exercises/if/if3.rs" +path = "exercises/03_if/if3.rs" mode = "test" hint = """ In Rust, every arm of an `if` expression has to return the same type of value. @@ -211,19 +211,19 @@ hint = "No hints this time ;)" [[exercises]] name = "primitive_types1" -path = "exercises/primitive_types/primitive_types1.rs" +path = "exercises/04_primitive_types/primitive_types1.rs" mode = "compile" hint = "No hints this time ;)" [[exercises]] name = "primitive_types2" -path = "exercises/primitive_types/primitive_types2.rs" +path = "exercises/04_primitive_types/primitive_types2.rs" mode = "compile" hint = "No hints this time ;)" [[exercises]] name = "primitive_types3" -path = "exercises/primitive_types/primitive_types3.rs" +path = "exercises/04_primitive_types/primitive_types3.rs" mode = "compile" hint = """ There's a shorthand to initialize Arrays with a certain size that does not @@ -239,7 +239,7 @@ for `a.len() >= 100`?""" [[exercises]] name = "primitive_types4" -path = "exercises/primitive_types/primitive_types4.rs" +path = "exercises/04_primitive_types/primitive_types4.rs" mode = "test" hint = """ Take a look at the 'Understanding Ownership -> Slices -> Other Slices' section @@ -254,7 +254,7 @@ https://doc.rust-lang.org/nomicon/coercions.html""" [[exercises]] name = "primitive_types5" -path = "exercises/primitive_types/primitive_types5.rs" +path = "exercises/04_primitive_types/primitive_types5.rs" mode = "compile" hint = """ Take a look at the 'Data Types -> The Tuple Type' section of the book: @@ -267,7 +267,7 @@ of the tuple. You can do it!!""" [[exercises]] name = "primitive_types6" -path = "exercises/primitive_types/primitive_types6.rs" +path = "exercises/04_primitive_types/primitive_types6.rs" mode = "test" hint = """ While you could use a destructuring `let` for the tuple here, try @@ -280,7 +280,7 @@ Now you have another tool in your toolbox!""" [[exercises]] name = "vecs1" -path = "exercises/vecs/vecs1.rs" +path = "exercises/05_vecs/vecs1.rs" mode = "test" hint = """ In Rust, there are two ways to define a Vector. @@ -295,7 +295,7 @@ of the Rust book to learn more. [[exercises]] name = "vecs2" -path = "exercises/vecs/vecs2.rs" +path = "exercises/05_vecs/vecs2.rs" mode = "test" hint = """ In the first function we are looping over the Vector and getting a reference to @@ -318,7 +318,7 @@ What do you think is the more commonly used pattern under Rust developers? [[exercises]] name = "move_semantics1" -path = "exercises/move_semantics/move_semantics1.rs" +path = "exercises/06_move_semantics/move_semantics1.rs" mode = "test" hint = """ So you've got the "cannot borrow immutable local variable `vec` as mutable" @@ -332,7 +332,7 @@ happens!""" [[exercises]] name = "move_semantics2" -path = "exercises/move_semantics/move_semantics2.rs" +path = "exercises/06_move_semantics/move_semantics2.rs" mode = "test" hint = """ When running this exercise for the first time, you'll notice an error about @@ -353,7 +353,7 @@ try them all: [[exercises]] name = "move_semantics3" -path = "exercises/move_semantics/move_semantics3.rs" +path = "exercises/06_move_semantics/move_semantics3.rs" mode = "test" hint = """ The difference between this one and the previous ones is that the first line @@ -363,7 +363,7 @@ an existing binding to be a mutable binding instead of an immutable one :)""" [[exercises]] name = "move_semantics4" -path = "exercises/move_semantics/move_semantics4.rs" +path = "exercises/06_move_semantics/move_semantics4.rs" mode = "test" hint = """ Stop reading whenever you feel like you have enough direction :) Or try @@ -377,7 +377,7 @@ So the end goal is to: [[exercises]] name = "move_semantics5" -path = "exercises/move_semantics/move_semantics5.rs" +path = "exercises/06_move_semantics/move_semantics5.rs" mode = "test" hint = """ Carefully reason about the range in which each mutable reference is in @@ -389,7 +389,7 @@ https://doc.rust-lang.org/book/ch04-02-references-and-borrowing.html#mutable-ref [[exercises]] name = "move_semantics6" -path = "exercises/move_semantics/move_semantics6.rs" +path = "exercises/06_move_semantics/move_semantics6.rs" mode = "compile" hint = """ To find the answer, you can consult the book section "References and Borrowing": @@ -410,7 +410,7 @@ Another hint: it has to do with the `&` character.""" [[exercises]] name = "structs1" -path = "exercises/structs/structs1.rs" +path = "exercises/07_structs/structs1.rs" mode = "test" hint = """ Rust has more than one type of struct. Three actually, all variants are used to @@ -430,7 +430,7 @@ https://doc.rust-lang.org/book/ch05-01-defining-structs.html""" [[exercises]] name = "structs2" -path = "exercises/structs/structs2.rs" +path = "exercises/07_structs/structs2.rs" mode = "test" hint = """ Creating instances of structs is easy, all you need to do is assign some values @@ -442,7 +442,7 @@ https://doc.rust-lang.org/stable/book/ch05-01-defining-structs.html#creating-ins [[exercises]] name = "structs3" -path = "exercises/structs/structs3.rs" +path = "exercises/07_structs/structs3.rs" mode = "test" hint = """ For `is_international`: What makes a package international? Seems related to @@ -458,13 +458,13 @@ https://doc.rust-lang.org/book/ch05-03-method-syntax.html""" [[exercises]] name = "enums1" -path = "exercises/enums/enums1.rs" +path = "exercises/08_enums/enums1.rs" mode = "compile" hint = "No hints this time ;)" [[exercises]] name = "enums2" -path = "exercises/enums/enums2.rs" +path = "exercises/08_enums/enums2.rs" mode = "compile" hint = """ You can create enumerations that have different variants with different types @@ -472,7 +472,7 @@ such as no data, anonymous structs, a single string, tuples, ...etc""" [[exercises]] name = "enums3" -path = "exercises/enums/enums3.rs" +path = "exercises/08_enums/enums3.rs" mode = "test" hint = """ As a first step, you can define enums to compile this code without errors. @@ -486,7 +486,7 @@ to get value in the variant.""" [[exercises]] name = "strings1" -path = "exercises/strings/strings1.rs" +path = "exercises/09_strings/strings1.rs" mode = "compile" hint = """ The `current_favorite_color` function is currently returning a string slice @@ -500,7 +500,7 @@ another way that uses the `From` trait.""" [[exercises]] name = "strings2" -path = "exercises/strings/strings2.rs" +path = "exercises/09_strings/strings2.rs" mode = "compile" hint = """ Yes, it would be really easy to fix this by just changing the value bound to @@ -515,7 +515,7 @@ https://doc.rust-lang.org/stable/book/ch15-02-deref.html#implicit-deref-coercion [[exercises]] name = "strings3" -path = "exercises/strings/strings3.rs" +path = "exercises/09_strings/strings3.rs" mode = "test" hint = """ There's tons of useful standard library functions for strings. Let's try and use some of them: @@ -526,7 +526,7 @@ the string slice into an owned string, which you can then freely extend.""" [[exercises]] name = "strings4" -path = "exercises/strings/strings4.rs" +path = "exercises/09_strings/strings4.rs" mode = "compile" hint = "No hints this time ;)" @@ -534,7 +534,7 @@ hint = "No hints this time ;)" [[exercises]] name = "modules1" -path = "exercises/modules/modules1.rs" +path = "exercises/10_modules/modules1.rs" mode = "compile" hint = """ Everything is private in Rust by default-- but there's a keyword we can use @@ -543,7 +543,7 @@ needs to be public.""" [[exercises]] name = "modules2" -path = "exercises/modules/modules2.rs" +path = "exercises/10_modules/modules2.rs" mode = "compile" hint = """ The delicious_snacks module is trying to present an external interface that is @@ -555,7 +555,7 @@ Learn more at https://doc.rust-lang.org/book/ch07-04-bringing-paths-into-scope-w [[exercises]] name = "modules3" -path = "exercises/modules/modules3.rs" +path = "exercises/10_modules/modules3.rs" mode = "compile" hint = """ `UNIX_EPOCH` and `SystemTime` are declared in the `std::time` module. Add a @@ -566,7 +566,7 @@ paths or the glob operator to bring these two in using only one line.""" [[exercises]] name = "hashmaps1" -path = "exercises/hashmaps/hashmaps1.rs" +path = "exercises/11_hashmaps/hashmaps1.rs" mode = "test" hint = """ Hint 1: Take a look at the return type of the function to figure out @@ -578,7 +578,7 @@ Hint 2: Number of fruits should be at least 5. And you have to put [[exercises]] name = "hashmaps2" -path = "exercises/hashmaps/hashmaps2.rs" +path = "exercises/11_hashmaps/hashmaps2.rs" mode = "test" hint = """ Use the `entry()` and `or_insert()` methods of `HashMap` to achieve this. @@ -587,7 +587,7 @@ Learn more at https://doc.rust-lang.org/stable/book/ch08-03-hash-maps.html#only- [[exercises]] name = "hashmaps3" -path = "exercises/hashmaps/hashmaps3.rs" +path = "exercises/11_hashmaps/hashmaps3.rs" mode = "test" hint = """ Hint 1: Use the `entry()` and `or_insert()` methods of `HashMap` to insert @@ -613,7 +613,7 @@ hint = "No hints this time ;)" [[exercises]] name = "options1" -path = "exercises/options/options1.rs" +path = "exercises/12_options/options1.rs" mode = "test" hint = """ Options can have a `Some` value, with an inner value, or a `None` value, @@ -625,7 +625,7 @@ it doesn't panic in your face later?""" [[exercises]] name = "options2" -path = "exercises/options/options2.rs" +path = "exercises/12_options/options2.rs" mode = "test" hint = """ Check out: @@ -642,7 +642,7 @@ Also see `Option::flatten` [[exercises]] name = "options3" -path = "exercises/options/options3.rs" +path = "exercises/12_options/options3.rs" mode = "compile" hint = """ The compiler says a partial move happened in the `match` statement. How can @@ -655,7 +655,7 @@ https://doc.rust-lang.org/std/keyword.ref.html""" [[exercises]] name = "errors1" -path = "exercises/error_handling/errors1.rs" +path = "exercises/13_error_handling/errors1.rs" mode = "test" hint = """ `Ok` and `Err` are the two variants of `Result`, so what the tests are saying @@ -671,7 +671,7 @@ To make this change, you'll need to: [[exercises]] name = "errors2" -path = "exercises/error_handling/errors2.rs" +path = "exercises/13_error_handling/errors2.rs" mode = "test" hint = """ One way to handle this is using a `match` statement on @@ -687,7 +687,7 @@ and give it a try!""" [[exercises]] name = "errors3" -path = "exercises/error_handling/errors3.rs" +path = "exercises/13_error_handling/errors3.rs" mode = "compile" hint = """ If other functions can return a `Result`, why shouldn't `main`? It's a fairly @@ -699,7 +699,7 @@ positive results.""" [[exercises]] name = "errors4" -path = "exercises/error_handling/errors4.rs" +path = "exercises/13_error_handling/errors4.rs" mode = "test" hint = """ `PositiveNonzeroInteger::new` is always creating a new instance and returning @@ -711,7 +711,7 @@ everything is... okay :)""" [[exercises]] name = "errors5" -path = "exercises/error_handling/errors5.rs" +path = "exercises/13_error_handling/errors5.rs" mode = "compile" hint = """ There are two different possible `Result` types produced within `main()`, which @@ -735,7 +735,7 @@ https://doc.rust-lang.org/stable/rust-by-example/error/multiple_error_types/reen [[exercises]] name = "errors6" -path = "exercises/error_handling/errors6.rs" +path = "exercises/13_error_handling/errors6.rs" mode = "test" hint = """ This exercise uses a completed version of `PositiveNonzeroInteger` from @@ -757,7 +757,7 @@ https://doc.rust-lang.org/std/result/enum.Result.html#method.map_err""" [[exercises]] name = "generics1" -path = "exercises/generics/generics1.rs" +path = "exercises/14_generics/generics1.rs" mode = "compile" hint = """ Vectors in Rust make use of generics to create dynamically sized arrays of any @@ -767,7 +767,7 @@ You need to tell the compiler what type we are pushing onto this vector.""" [[exercises]] name = "generics2" -path = "exercises/generics/generics2.rs" +path = "exercises/14_generics/generics2.rs" mode = "test" hint = """ Currently we are wrapping only values of type `u32`. @@ -781,7 +781,7 @@ If you are still stuck https://doc.rust-lang.org/stable/book/ch10-01-syntax.html [[exercises]] name = "traits1" -path = "exercises/traits/traits1.rs" +path = "exercises/15_traits/traits1.rs" mode = "test" hint = """ A discussion about Traits in Rust can be found at: @@ -790,7 +790,7 @@ https://doc.rust-lang.org/book/ch10-02-traits.html [[exercises]] name = "traits2" -path = "exercises/traits/traits2.rs" +path = "exercises/15_traits/traits2.rs" mode = "test" hint = """ Notice how the trait takes ownership of `self`, and returns `Self`. @@ -803,7 +803,7 @@ the documentation at: https://doc.rust-lang.org/std/vec/struct.Vec.html""" [[exercises]] name = "traits3" -path = "exercises/traits/traits3.rs" +path = "exercises/15_traits/traits3.rs" mode = "test" hint = """ Traits can have a default implementation for functions. Structs that implement @@ -815,7 +815,7 @@ See the documentation at: https://doc.rust-lang.org/book/ch10-02-traits.html#def [[exercises]] name = "traits4" -path = "exercises/traits/traits4.rs" +path = "exercises/15_traits/traits4.rs" mode = "test" hint = """ Instead of using concrete types as parameters you can use traits. Try replacing @@ -826,7 +826,7 @@ See the documentation at: https://doc.rust-lang.org/book/ch10-02-traits.html#tra [[exercises]] name = "traits5" -path = "exercises/traits/traits5.rs" +path = "exercises/15_traits/traits5.rs" mode = "compile" hint = """ To ensure a parameter implements multiple traits use the '+ syntax'. Try @@ -851,7 +851,7 @@ You may also need this: `use std::fmt::Display;`.""" [[exercises]] name = "lifetimes1" -path = "exercises/lifetimes/lifetimes1.rs" +path = "exercises/16_lifetimes/lifetimes1.rs" mode = "compile" hint = """ Let the compiler guide you. Also take a look at the book if you need help: @@ -859,7 +859,7 @@ https://doc.rust-lang.org/book/ch10-03-lifetime-syntax.html""" [[exercises]] name = "lifetimes2" -path = "exercises/lifetimes/lifetimes2.rs" +path = "exercises/16_lifetimes/lifetimes2.rs" mode = "compile" hint = """ Remember that the generic lifetime `'a` will get the concrete lifetime that is @@ -873,7 +873,7 @@ inner block: [[exercises]] name = "lifetimes3" -path = "exercises/lifetimes/lifetimes3.rs" +path = "exercises/16_lifetimes/lifetimes3.rs" mode = "compile" hint = """ If you use a lifetime annotation in a struct's fields, where else does it need @@ -883,7 +883,7 @@ to be added?""" [[exercises]] name = "tests1" -path = "exercises/tests/tests1.rs" +path = "exercises/17_tests/tests1.rs" mode = "test" hint = """ You don't even need to write any code to test -- you can just test values and @@ -898,7 +898,7 @@ ones pass, and which ones fail :)""" [[exercises]] name = "tests2" -path = "exercises/tests/tests2.rs" +path = "exercises/17_tests/tests2.rs" mode = "test" hint = """ Like the previous exercise, you don't need to write any code to get this test @@ -911,7 +911,7 @@ argument comes first and which comes second!""" [[exercises]] name = "tests3" -path = "exercises/tests/tests3.rs" +path = "exercises/17_tests/tests3.rs" mode = "test" hint = """ You can call a function right where you're passing arguments to `assert!`. So @@ -922,7 +922,7 @@ what you're doing using `!`, like `assert!(!having_fun())`.""" [[exercises]] name = "tests4" -path = "exercises/tests/tests4.rs" +path = "exercises/17_tests/tests4.rs" mode = "test" hint = """ We expect method `Rectangle::new()` to panic for negative values. @@ -936,7 +936,7 @@ https://doc.rust-lang.org/stable/book/ch11-01-writing-tests.html#checking-for-pa [[exercises]] name = "iterators1" -path = "exercises/iterators/iterators1.rs" +path = "exercises/18_iterators/iterators1.rs" mode = "test" hint = """ Step 1: @@ -959,7 +959,7 @@ https://doc.rust-lang.org/std/iter/trait.Iterator.html for some ideas. [[exercises]] name = "iterators2" -path = "exercises/iterators/iterators2.rs" +path = "exercises/18_iterators/iterators2.rs" mode = "test" hint = """ Step 1: @@ -985,7 +985,7 @@ powerful and very general. Rust just needs to know the desired type.""" [[exercises]] name = "iterators3" -path = "exercises/iterators/iterators3.rs" +path = "exercises/18_iterators/iterators3.rs" mode = "test" hint = """ The `divide` function needs to return the correct error when even division is @@ -1004,7 +1004,7 @@ powerful! It can make the solution to this exercise infinitely easier.""" [[exercises]] name = "iterators4" -path = "exercises/iterators/iterators4.rs" +path = "exercises/18_iterators/iterators4.rs" mode = "test" hint = """ In an imperative language, you might write a `for` loop that updates a mutable @@ -1016,7 +1016,7 @@ Hint 2: Check out the `fold` and `rfold` methods!""" [[exercises]] name = "iterators5" -path = "exercises/iterators/iterators5.rs" +path = "exercises/18_iterators/iterators5.rs" mode = "test" hint = """ The documentation for the `std::iter::Iterator` trait contains numerous methods @@ -1035,7 +1035,7 @@ a different method that could make your code more compact than using `fold`.""" [[exercises]] name = "box1" -path = "exercises/smart_pointers/box1.rs" +path = "exercises/19_smart_pointers/box1.rs" mode = "test" hint = """ Step 1: @@ -1059,7 +1059,7 @@ definition and try other types! [[exercises]] name = "rc1" -path = "exercises/smart_pointers/rc1.rs" +path = "exercises/19_smart_pointers/rc1.rs" mode = "test" hint = """ This is a straightforward exercise to use the `Rc` type. Each `Planet` has @@ -1078,7 +1078,7 @@ See more at: https://doc.rust-lang.org/book/ch15-04-rc.html [[exercises]] name = "arc1" -path = "exercises/smart_pointers/arc1.rs" +path = "exercises/19_smart_pointers/arc1.rs" mode = "compile" hint = """ Make `shared_numbers` be an `Arc` from the numbers vector. Then, in order @@ -1096,7 +1096,7 @@ https://doc.rust-lang.org/stable/book/ch16-00-concurrency.html [[exercises]] name = "cow1" -path = "exercises/smart_pointers/cow1.rs" +path = "exercises/19_smart_pointers/cow1.rs" mode = "test" hint = """ If `Cow` already owns the data it doesn't need to clone it when `to_mut()` is @@ -1110,7 +1110,7 @@ on the `Cow` type. [[exercises]] name = "threads1" -path = "exercises/threads/threads1.rs" +path = "exercises/20_threads/threads1.rs" mode = "compile" hint = """ `JoinHandle` is a struct that is returned from a spawned thread: @@ -1128,7 +1128,7 @@ https://doc.rust-lang.org/std/thread/struct.JoinHandle.html [[exercises]] name = "threads2" -path = "exercises/threads/threads2.rs" +path = "exercises/20_threads/threads2.rs" mode = "compile" hint = """ `Arc` is an Atomic Reference Counted pointer that allows safe, shared access @@ -1158,7 +1158,7 @@ what you've learned :)""" [[exercises]] name = "threads3" -path = "exercises/threads/threads3.rs" +path = "exercises/20_threads/threads3.rs" mode = "test" hint = """ An alternate way to handle concurrency between threads is to use an `mpsc` @@ -1177,7 +1177,7 @@ See https://doc.rust-lang.org/book/ch16-02-message-passing.html for more info. [[exercises]] name = "macros1" -path = "exercises/macros/macros1.rs" +path = "exercises/21_macros/macros1.rs" mode = "compile" hint = """ When you call a macro, you need to add something special compared to a @@ -1186,7 +1186,7 @@ regular function call. If you're stuck, take a look at what's inside [[exercises]] name = "macros2" -path = "exercises/macros/macros2.rs" +path = "exercises/21_macros/macros2.rs" mode = "compile" hint = """ Macros don't quite play by the same rules as the rest of Rust, in terms of @@ -1197,7 +1197,7 @@ Unlike other things in Rust, the order of "where you define a macro" versus [[exercises]] name = "macros3" -path = "exercises/macros/macros3.rs" +path = "exercises/21_macros/macros3.rs" mode = "compile" hint = """ In order to use a macro outside of its module, you need to do something @@ -1208,7 +1208,7 @@ exported macros, if you've seen any of those around.""" [[exercises]] name = "macros4" -path = "exercises/macros/macros4.rs" +path = "exercises/21_macros/macros4.rs" mode = "compile" hint = """ You only need to add a single character to make this compile. @@ -1225,7 +1225,7 @@ https://veykril.github.io/tlborm/""" [[exercises]] name = "clippy1" -path = "exercises/clippy/clippy1.rs" +path = "exercises/22_clippy/clippy1.rs" mode = "clippy" hint = """ Rust stores the highest precision version of any long or infinite precision @@ -1241,14 +1241,14 @@ appropriate replacement constant from `std::f32::consts`...""" [[exercises]] name = "clippy2" -path = "exercises/clippy/clippy2.rs" +path = "exercises/22_clippy/clippy2.rs" mode = "clippy" hint = """ `for` loops over `Option` values are more clearly expressed as an `if let`""" [[exercises]] name = "clippy3" -path = "exercises/clippy/clippy3.rs" +path = "exercises/22_clippy/clippy3.rs" mode = "clippy" hint = "No hints this time!" @@ -1256,7 +1256,7 @@ hint = "No hints this time!" [[exercises]] name = "using_as" -path = "exercises/conversions/using_as.rs" +path = "exercises/23_conversions/using_as.rs" mode = "test" hint = """ Use the `as` operator to cast one of the operands in the last line of the @@ -1264,14 +1264,14 @@ Use the `as` operator to cast one of the operands in the last line of the [[exercises]] name = "from_into" -path = "exercises/conversions/from_into.rs" +path = "exercises/23_conversions/from_into.rs" mode = "test" hint = """ Follow the steps provided right before the `From` implementation""" [[exercises]] name = "from_str" -path = "exercises/conversions/from_str.rs" +path = "exercises/23_conversions/from_str.rs" mode = "test" hint = """ The implementation of `FromStr` should return an `Ok` with a `Person` object, @@ -1292,7 +1292,7 @@ https://doc.rust-lang.org/stable/rust-by-example/error/multiple_error_types/reen [[exercises]] name = "try_from_into" -path = "exercises/conversions/try_from_into.rs" +path = "exercises/23_conversions/try_from_into.rs" mode = "test" hint = """ Follow the steps provided right before the `TryFrom` implementation. @@ -1315,7 +1315,7 @@ Challenge: Can you make the `TryFrom` implementations generic over many integer [[exercises]] name = "as_ref_mut" -path = "exercises/conversions/as_ref_mut.rs" +path = "exercises/23_conversions/as_ref_mut.rs" mode = "test" hint = """ Add `AsRef` or `AsMut` as a trait bound to the functions.""" From 3c4fde46106efab749ab9af9fe76f5e75779ef5d Mon Sep 17 00:00:00 2001 From: markgreene74 Date: Mon, 16 Oct 2023 22:41:34 +0100 Subject: [PATCH 23/32] fix(watch): update the CLIPPY_CARGO_TOML_PATH ... to reflect the changes to the exercise directory names. The path exercises/clippy replaced with exercises/22_clippy. closes #1726 --- src/exercise.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/exercise.rs b/src/exercise.rs index c7b5672d..664b362b 100644 --- a/src/exercise.rs +++ b/src/exercise.rs @@ -12,7 +12,7 @@ const RUSTC_EDITION_ARGS: &[&str] = &["--edition", "2021"]; const RUSTC_NO_DEBUG_ARGS: &[&str] = &["-C", "strip=debuginfo"]; const I_AM_DONE_REGEX: &str = r"(?m)^\s*///?\s*I\s+AM\s+NOT\s+DONE"; const CONTEXT: usize = 2; -const CLIPPY_CARGO_TOML_PATH: &str = "./exercises/clippy/Cargo.toml"; +const CLIPPY_CARGO_TOML_PATH: &str = "./exercises/22_clippy/Cargo.toml"; // Get a temporary file name that is hopefully unique #[inline] From 3545c5a7a403bda177084564c7ceedad50aec8e0 Mon Sep 17 00:00:00 2001 From: markgreene74 Date: Mon, 16 Oct 2023 22:53:21 +0100 Subject: [PATCH 24/32] fix(intro1.rs): typo in the exercise body --- exercises/00_intro/intro1.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/00_intro/intro1.rs b/exercises/00_intro/intro1.rs index c5196d62..5dd18b45 100644 --- a/exercises/00_intro/intro1.rs +++ b/exercises/00_intro/intro1.rs @@ -29,7 +29,7 @@ fn main() { println!("or logic error. The central concept behind Rustlings is to fix these errors and"); println!("solve the exercises. Good luck!"); println!(); - println!("The source for this exercise is in `exercises/intro00/intro1.rs`. Have a look!"); + println!("The source for this exercise is in `exercises/00_intro/intro1.rs`. Have a look!"); println!( "Going forward, the source of the exercises will always be in the success/failure output." ); From d757726aca44bbb4f96de21990c29714a0a497ca Mon Sep 17 00:00:00 2001 From: Versha Dhankar <45564258+VeeDeltaVee@users.noreply.github.com> Date: Tue, 17 Oct 2023 11:54:59 -0700 Subject: [PATCH 25/32] docs: fix windows installation instructions Currently, the windows installation instructions download a script from the URL ps1.rustlings.cool. This URL isn't detected as a URL in some cases, which means that PowerShell tries to load the data from a local file called ps1.rustlings.cool. This was breaking my install, and adding the https:// fixed it. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cf001e28..42e282e0 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser Then, you can run: ```ps1 -Start-BitsTransfer -Source ps1.rustlings.cool -Destination $env:TMP/install_rustlings.ps1; Unblock-File $env:TMP/install_rustlings.ps1; Invoke-Expression $env:TMP/install_rustlings.ps1 +Start-BitsTransfer -Source https://ps1.rustlings.cool -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. Keep in mind that this works best in PowerShell, and any other terminals may give you errors. From be6630bec6fa0d08352ee70f31cb8e4e091fc64a Mon Sep 17 00:00:00 2001 From: The Bearodactyl <114454115+TheBearodactyl@users.noreply.github.com> Date: Wed, 18 Oct 2023 18:59:58 +0000 Subject: [PATCH 26/32] Update install.sh --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 9aca5b68..5915a33d 100755 --- a/install.sh +++ b/install.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -euo pipefail -echo "Let's get you set up with Rustlings!" +echo -e "\nLet's get you set up with Rustlings!" echo "Checking requirements..." if [ -x "$(command -v git)" ] From 9394825018475e77915932e93300a30c8d392db1 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Wed, 18 Oct 2023 21:32:32 +0000 Subject: [PATCH 27/32] docs: update AUTHORS.md [skip ci] --- AUTHORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS.md b/AUTHORS.md index f3807bba..f7174a36 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -348,6 +348,7 @@ authors. d1t2
d1t2

๐Ÿš‡ docwilco
docwilco

๐Ÿ’ป Matt Nield
Matt Nield

๐Ÿ–‹ + The Bearodactyl
The Bearodactyl

๐Ÿ’ป From faa261e3e20b17f65b609916ec351712b91595c1 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Wed, 18 Oct 2023 21:32:33 +0000 Subject: [PATCH 28/32] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 42f04e49..51e14a0a 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -2469,6 +2469,15 @@ "contributions": [ "content" ] + }, + { + "login": "TheBearodactyl", + "name": "The Bearodactyl", + "avatar_url": "https://avatars.githubusercontent.com/u/114454115?v=4", + "profile": "https://github.com/TheBearodactyl", + "contributions": [ + "code" + ] } ], "contributorsPerLine": 8, From a4698d8e1043c01b61ce42ad62535c13c1934453 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Wed, 18 Oct 2023 21:33:37 +0000 Subject: [PATCH 29/32] docs: update AUTHORS.md [skip ci] --- AUTHORS.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/AUTHORS.md b/AUTHORS.md index f7174a36..4fa91c06 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -350,6 +350,9 @@ authors. Matt Nield
Matt Nield

๐Ÿ–‹ The Bearodactyl
The Bearodactyl

๐Ÿ’ป + + markgreene74
markgreene74

๐Ÿ’ป + From 5b25de927e89f138779ad82963cc50c6d8def4ff Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Wed, 18 Oct 2023 21:33:38 +0000 Subject: [PATCH 30/32] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 51e14a0a..232aac3d 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -2478,6 +2478,15 @@ "contributions": [ "code" ] + }, + { + "login": "markgreene74", + "name": "markgreene74", + "avatar_url": "https://avatars.githubusercontent.com/u/18945890?v=4", + "profile": "https://github.com/markgreene74", + "contributions": [ + "code" + ] } ], "contributorsPerLine": 8, From c5c33578d9d1cad9f1df4b220d32a046dd4668a0 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Wed, 18 Oct 2023 21:34:40 +0000 Subject: [PATCH 31/32] docs: update AUTHORS.md [skip ci] --- AUTHORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS.md b/AUTHORS.md index 4fa91c06..a120b0a8 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -352,6 +352,7 @@ authors. markgreene74
markgreene74

๐Ÿ’ป + Versha Dhankar
Versha Dhankar

๐Ÿ“– From e74a7001ef29d482b6b28b4dbf3c7db952adeac9 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Wed, 18 Oct 2023 21:34:41 +0000 Subject: [PATCH 32/32] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 232aac3d..574ac662 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -2487,6 +2487,15 @@ "contributions": [ "code" ] + }, + { + "login": "VeeDeltaVee", + "name": "Versha Dhankar", + "avatar_url": "https://avatars.githubusercontent.com/u/45564258?v=4", + "profile": "https://github.com/VeeDeltaVee", + "contributions": [ + "doc" + ] } ], "contributorsPerLine": 8,