From 55a9284665dc6ef5d9db6f73e76630f22d3ea43d Mon Sep 17 00:00:00 2001 From: mokou Date: Sun, 14 Jun 2020 14:48:51 +0200 Subject: [PATCH 001/282] chore: Move from master branch to main branch --- install.sh | 4 ++-- src/exercise.rs | 2 +- src/main.rs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/install.sh b/install.sh index c32f5126..a19c280a 100755 --- a/install.sh +++ b/install.sh @@ -115,8 +115,8 @@ then if [[ -z ${Version} ]] then echo "No valid tag version found" - echo "Rustlings will be installed using the master branch" - Version="master" + echo "Rustlings will be installed using the main branch" + Version="main" else Version="tags/${Version}" fi diff --git a/src/exercise.rs b/src/exercise.rs index 177b7f38..2108d81e 100644 --- a/src/exercise.rs +++ b/src/exercise.rs @@ -134,7 +134,7 @@ path = "{}.rs""#, .expect("Failed to compile!"); // Due to an issue with Clippy, a cargo clean is required to catch all lints. // See https://github.com/rust-lang/rust-clippy/issues/2604 - // This is already fixed on master branch. See this issue to track merging into Cargo: + // This is already fixed on Clippy's master branch. See this issue to track merging into Cargo: // https://github.com/rust-lang/rust-clippy/issues/3837 Command::new("cargo") .args(&["clean", "--manifest-path", CLIPPY_CARGO_TOML_PATH]) diff --git a/src/main.rs b/src/main.rs index 9c64de2b..aa67aca6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -132,7 +132,7 @@ fn main() { println!("You can also contribute your own exercises to help the greater community!"); println!(); println!("Before reporting an issue or contributing, please read our guidelines:"); - println!("https://github.com/rust-lang/rustlings/blob/master/CONTRIBUTING.md"); + println!("https://github.com/rust-lang/rustlings/blob/main/CONTRIBUTING.md"); } if matches.subcommand_name().is_none() { From ddd98ad75d3668fbb10eff74374148aa5ed2344d Mon Sep 17 00:00:00 2001 From: iamcastelli Date: Sat, 27 Jun 2020 15:58:53 +0400 Subject: [PATCH 002/282] fix: Change then to than `than` makes more grammatical sense than `then` in this context. --- info.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/info.toml b/info.toml index ee4ab2f6..46e353ff 100644 --- a/info.toml +++ b/info.toml @@ -64,7 +64,7 @@ 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 -then keyword 'let'. +than keyword 'let'. Constants types must also always be annotated. Read more about constants under 'Differences Between Variables and Constants' in the book's section 'Variables and Mutability': From f9ccc6a289ca5fed784fd45878b163e633bfdba1 Mon Sep 17 00:00:00 2001 From: mokou Date: Wed, 8 Jul 2020 11:35:27 +0200 Subject: [PATCH 003/282] release: 4.0.0 --- CHANGELOG.md | 42 ++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 2 +- README.md | 2 +- 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f72c9607..594987c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,45 @@ + +## 4.0.0 (2020-07-08) + +#### Breaking Changes + +* Add a --nocapture option to display test harnesses' outputs ([8ad5f9bf](https://github.com/rust-lang/rustlings/commit/8ad5f9bf531a4848b1104b7b389a20171624c82f) +* Rename test to quiz, fixes #244 ([010a0456](https://github.com/rust-lang/rustlings/commit/010a04569282149cea7f7a76fc4d7f4c9f0f08dd) + +#### Features + +* Add traits README ([173bb141](https://github.com/rust-lang/rustlings/commit/173bb14140c5530cbdb59e53ace3991a99d804af)) +* Add box1.rs exercise ([7479a473](https://github.com/rust-lang/rustlings/commit/7479a4737bdcac347322ad0883ca528c8675e720)) +* Rewrite try_from_into (#393) ([763aa6e3](https://github.com/rust-lang/rustlings/commit/763aa6e378a586caae2d8d63755a85eeba227933)) +* Add if2 exercise ([1da84b5f](https://github.com/rust-lang/rustlings/commit/1da84b5f7c489f65bd683c244f13c7d1ee812df0)) +* Added exercise structs3.rs ([b66e2e09](https://github.com/rust-lang/rustlings/commit/b66e2e09622243e086a0f1258dd27e1a2d61c891)) +* Add exercise variables6 covering const (#352) ([5999acd2](https://github.com/rust-lang/rustlings/commit/5999acd24a4f203292be36e0fd18d385887ec481)) + +#### Bug Fixes + +* Change then to than ([ddd98ad7](https://github.com/rust-lang/rustlings/commit/ddd98ad75d3668fbb10eff74374148aa5ed2344d)) +* rename quiz1 to tests1 in info (#420) ([0dd1c6ca](https://github.com/rust-lang/rustlings/commit/0dd1c6ca6b389789e0972aa955fe17aa15c95f29)) +* fix quiz naming inconsistency (#421) ([5563adbb](https://github.com/rust-lang/rustlings/commit/5563adbb890587fc48fbbc9c4028642687f1e85b)) +* confine the user further in variable exercises ([06ef4cc6](https://github.com/rust-lang/rustlings/commit/06ef4cc654e75d22a526812919ee49b8956280bf)) +* update iterator and macro text for typos and clarity ([95900828](https://github.com/rust-lang/rustlings/commit/959008284834bece0196a01e17ac69a7e3590116)) +* update generics2 closes #362 ([964c974a](https://github.com/rust-lang/rustlings/commit/964c974a0274199d755073b917c2bc5da0c9b4f1)) +* confusing comment in conversions/try_from_into.rs ([c9e4f2cf](https://github.com/rust-lang/rustlings/commit/c9e4f2cfb4c48d0b7451263cfb43b9426438122d)) +* **arc1:** Passively introduce attributes (#429) ([113cdae2](https://github.com/rust-lang/rustlings/commit/113cdae2d4e4c55905e8056ad326ede7fd7de356)) +* **box1:** fix comment typo (#426) ([bb2ca251](https://github.com/rust-lang/rustlings/commit/bb2ca251106b27a7272d9a30872904dd1376654c)) +* **errorsn:** Try harder to confine the user. (#388) ([2b20c8a0](https://github.com/rust-lang/rustlings/commit/2b20c8a0f5774d07c58d110d75879f33fc6273b5)) +* **from_into.rs:** typo ([a901499e](https://github.com/rust-lang/rustlings/commit/a901499ededd3ce1995164700514fe4e9a0373ea)) +* **generics2:** Guide students to the answer (#430) ([e6bd8021](https://github.com/rust-lang/rustlings/commit/e6bd8021d9a7dd06feebc30c9d5f953901d7b419)) +* **installation:** + * Provide a backup git reference when tag can't be curl ([9e4fb100](https://github.com/rust-lang/rustlings/commit/9e4fb1009f1c9e3433915c03e22c2af422e5c5fe)) + * Check if python is available while checking for git,rustc and cargo ([9cfb617d](https://github.com/rust-lang/rustlings/commit/9cfb617d5b0451b4b51644a1298965390cda9884)) +* **option1:** + * Don't add only zeros to the numbers array ([cce6a442](https://github.com/rust-lang/rustlings/commit/cce6a4427718724a9096800754cd3abeca6a1580)) + * Add cast to usize, as it is confusing in the context of an exercise about Option ([f6cffc7e](https://github.com/rust-lang/rustlings/commit/f6cffc7e487b42f15a6f958e49704c93a8d4465b)) +* **option2:** Add TODO to comments (#400) ([10967bce](https://github.com/rust-lang/rustlings/commit/10967bce57682812dc0891a9f9757da1a9d87404)) +* **options1:** Add hint about Array Initialization (#389) ([9f75554f](https://github.com/rust-lang/rustlings/commit/9f75554f2a30295996f03f0160b98c0458305502)) +* **test2:** name of type String and &str (#394) ([d6c0a688](https://github.com/rust-lang/rustlings/commit/d6c0a688e6a96f93ad60d540d4b326f342fc0d45)) +* **variables6:** minor typo (#419) ([524e17df](https://github.com/rust-lang/rustlings/commit/524e17df10db95f7b90a0f75cc8997182a8a4094)) + ## 3.0.0 (2020-04-11) diff --git a/Cargo.toml b/Cargo.toml index 3481a886..d4180da2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rustlings" -version = "3.0.0" +version = "4.0.0" authors = ["Marisa ", "Carol (Nichols || Goulding) "] edition = "2018" diff --git a/README.md b/README.md index 6724f05a..3e260122 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ Basically: Clone the repository, checkout to the latest tag, run `cargo install` ```bash git clone https://github.com/rust-lang/rustlings cd rustlings -git checkout tags/3.0.0 # or whatever the latest version is (find out at https://github.com/rust-lang/rustlings/releases/latest) +git checkout tags/4.0.0 # or whatever the latest version is (find out at https://github.com/rust-lang/rustlings/releases/latest) cargo install --force --path . ``` From e823bef97063560170c6c286ae03e40fb50ea5b8 Mon Sep 17 00:00:00 2001 From: mokou Date: Wed, 8 Jul 2020 11:43:08 +0200 Subject: [PATCH 004/282] docs: Add missing closing brackets to changelog --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 594987c1..0d984eb6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,8 +3,8 @@ #### Breaking Changes -* Add a --nocapture option to display test harnesses' outputs ([8ad5f9bf](https://github.com/rust-lang/rustlings/commit/8ad5f9bf531a4848b1104b7b389a20171624c82f) -* Rename test to quiz, fixes #244 ([010a0456](https://github.com/rust-lang/rustlings/commit/010a04569282149cea7f7a76fc4d7f4c9f0f08dd) +* Add a --nocapture option to display test harnesses' outputs ([8ad5f9bf](https://github.com/rust-lang/rustlings/commit/8ad5f9bf531a4848b1104b7b389a20171624c82f)) +* Rename test to quiz, fixes #244 ([010a0456](https://github.com/rust-lang/rustlings/commit/010a04569282149cea7f7a76fc4d7f4c9f0f08dd)) #### Features From 816b1f5e85d6cc6e72673813a85d0ada2a8f84af Mon Sep 17 00:00:00 2001 From: Alexx Roche Date: Wed, 8 Jul 2020 11:51:12 +0200 Subject: [PATCH 005/282] feat: Remind the user of the hint option (#425) Suggestion from AbdouSeck https://github.com/rust-lang/rustlings/issues/424#issuecomment-639870331 for when the student's code has errors. --- src/verify.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/verify.rs b/src/verify.rs index fac04919..807bea9e 100644 --- a/src/verify.rs +++ b/src/verify.rs @@ -65,6 +65,7 @@ fn compile_and_run_interactively(exercise: &Exercise) -> Result { Err(output) => { warn!("Ran {} with errors", exercise); println!("{}", output.stdout); + println!("{}", output.stderr); return Err(()); } }; From 4b6540c71adabad647de8a09e57295e7c7c7d794 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?DEWA=20Kazuyuki/=E5=87=BA=E7=BE=BD=E5=92=8C=E4=B9=8B?= Date: Wed, 8 Jul 2020 18:56:43 +0900 Subject: [PATCH 006/282] fix(enums3): Update Message::ChangeColor to take a tuple. (#457) --- exercises/enums/enums3.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/enums/enums3.rs b/exercises/enums/enums3.rs index 4b0be975..e9621b8e 100644 --- a/exercises/enums/enums3.rs +++ b/exercises/enums/enums3.rs @@ -51,7 +51,7 @@ mod tests { position: Point{ x: 0, y: 0 }, color: (0, 0, 0) }; - state.process(Message::ChangeColor(255, 0, 255)); + state.process(Message::ChangeColor((255, 0, 255))); state.process(Message::Echo(String::from("hello world"))); state.process(Message::Move(Point{ x: 10, y: 15 })); state.process(Message::Quit); From 106dbbc341bd7846745b37e2203e206abf83ed20 Mon Sep 17 00:00:00 2001 From: Philip Pokarowski <2538022+Nuc1eoN@users.noreply.github.com> Date: Thu, 9 Jul 2020 09:25:50 +0200 Subject: [PATCH 007/282] Update README.md (#464) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3e260122..f1fc764c 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,7 @@ Then, same as above, run `rustlings` to get started. The exercises are sorted by topic and can be found in the subdirectory `rustlings/exercises/`. For every topic there is an additional README file with some resources to get you started on the topic. We really recommend that you have a look at them before you start. -The task is simple. Most exercises contain an error that keep it from compiling, and it's up to you to fix it! Some exercises are also run as tests, but rustlings handles them all the same. To run the exercises in the recommended order, execute: +The task is simple. Most exercises contain an error that keep them from compiling, and it's up to you to fix it! Some exercises are also run as tests, but rustlings handles them all the same. To run the exercises in the recommended order, execute: ```bash rustlings watch From bb5f404e35f0091b4beb691105e7ed2a94ce4a13 Mon Sep 17 00:00:00 2001 From: Benjamin Jones Date: Fri, 10 Jul 2020 19:01:38 -0700 Subject: [PATCH 008/282] chore: Alter whitespace for consistency * Add newline after "I AM DONE" in exercises for consistency * Remove trailing whitespace from exercises --- exercises/conversions/as_ref_mut.rs | 1 + exercises/conversions/from_into.rs | 4 +++- exercises/conversions/using_as.rs | 6 ++++-- exercises/generics/generics1.rs | 2 +- exercises/generics/generics2.rs | 5 +++-- exercises/generics/generics3.rs | 21 ++++++++++--------- exercises/primitive_types/primitive_types3.rs | 2 +- exercises/structs/structs3.rs | 6 +++--- exercises/traits/traits1.rs | 9 ++++---- exercises/traits/traits2.rs | 7 +++---- 10 files changed, 34 insertions(+), 29 deletions(-) diff --git a/exercises/conversions/as_ref_mut.rs b/exercises/conversions/as_ref_mut.rs index 963c0f2d..84f4a60c 100644 --- a/exercises/conversions/as_ref_mut.rs +++ b/exercises/conversions/as_ref_mut.rs @@ -3,6 +3,7 @@ // and https://doc.rust-lang.org/std/convert/trait.AsMut.html, respectively. // I AM NOT DONE + // Obtain the number of bytes (not characters) in the given argument // Add the AsRef trait appropriately as a trait bound fn byte_counter(arg: T) -> usize { diff --git a/exercises/conversions/from_into.rs b/exercises/conversions/from_into.rs index 8fb9eb05..4f4da538 100644 --- a/exercises/conversions/from_into.rs +++ b/exercises/conversions/from_into.rs @@ -18,7 +18,6 @@ impl Default for Person { } } -// I AM NOT DONE // Your task is to complete this implementation // in order for the line `let p = Person::from("Mark,20")` to compile // Please note that you'll need to parse the age component into a `usize` @@ -33,6 +32,9 @@ impl Default for Person { // 5. Extract the other element from the split operation and parse it into a `usize` as the age // If while parsing the age, something goes wrong, then return the default of Person // Otherwise, then return an instantiated Person object with the results + +// I AM NOT DONE + impl From<&str> for Person { fn from(s: &str) -> Person { } diff --git a/exercises/conversions/using_as.rs b/exercises/conversions/using_as.rs index 54f96515..922abae0 100644 --- a/exercises/conversions/using_as.rs +++ b/exercises/conversions/using_as.rs @@ -1,9 +1,11 @@ // Type casting in Rust is done via the usage of the `as` operator. // Please note that the `as` operator is not only used when type casting. // It also helps with renaming imports. +// +// The goal is to make sure that the division does not fail to compile // I AM NOT DONE -// The goal is to make sure that the division does not fail to compile + fn average(values: &[f64]) -> f64 { let total = values .iter() @@ -14,4 +16,4 @@ fn average(values: &[f64]) -> f64 { fn main() { let values = [3.5, 0.3, 13.0, 11.7]; println!("{}", average(&values)); -} \ No newline at end of file +} diff --git a/exercises/generics/generics1.rs b/exercises/generics/generics1.rs index d075a4d2..1e6ae9d7 100644 --- a/exercises/generics/generics1.rs +++ b/exercises/generics/generics1.rs @@ -1,4 +1,4 @@ -// This shopping list program isn't compiling! +// This shopping list program isn't compiling! // Use your knowledge of generics to fix it. // I AM NOT DONE diff --git a/exercises/generics/generics2.rs b/exercises/generics/generics2.rs index 23025aaa..20c21279 100644 --- a/exercises/generics/generics2.rs +++ b/exercises/generics/generics2.rs @@ -2,6 +2,7 @@ // Rewrite it using generics so that it supports wrapping ANY type. // I AM NOT DONE + struct Wrapper { value: u32 } @@ -18,11 +19,11 @@ mod tests { #[test] fn store_u32_in_wrapper() { - assert_eq!(Wrapper::new(42).value, 42); + assert_eq!(Wrapper::new(42).value, 42); } #[test] fn store_str_in_wrapper() { assert_eq!(Wrapper::new("Foo").value, "Foo"); } -} \ No newline at end of file +} diff --git a/exercises/generics/generics3.rs b/exercises/generics/generics3.rs index c76425c3..760028ed 100644 --- a/exercises/generics/generics3.rs +++ b/exercises/generics/generics3.rs @@ -1,13 +1,14 @@ // An imaginary magical school has a new report card generation system written in Rust! -// Currently the system only supports creating report cards where the student's grade -// is represented numerically (e.g. 1.0 -> 5.5). -// However, the school also issues alphabetical grades (A+ -> F-) and needs +// Currently the system only supports creating report cards where the student's grade +// is represented numerically (e.g. 1.0 -> 5.5). +// However, the school also issues alphabetical grades (A+ -> F-) and needs // to be able to print both types of report card! -// Make the necessary code changes to support alphabetical report cards, thereby making +// Make the necessary code changes to support alphabetical report cards, thereby making // the second test pass. // I AM NOT DONE + pub struct ReportCard { pub grade: f32, pub student_name: String, @@ -16,7 +17,7 @@ pub struct ReportCard { impl ReportCard { pub fn print(&self) -> String { - format!("{} ({}) - achieved a grade of {}", + format!("{} ({}) - achieved a grade of {}", &self.student_name, &self.student_age, &self.grade) } } @@ -28,8 +29,8 @@ mod tests { #[test] fn generate_numeric_report_card() { let report_card = ReportCard { - grade: 2.1, - student_name: "Tom Wriggle".to_string(), + grade: 2.1, + student_name: "Tom Wriggle".to_string(), student_age: 12, }; assert_eq!(report_card.print(), "Tom Wriggle (12) - achieved a grade of 2.1"); @@ -39,10 +40,10 @@ mod tests { fn generate_alphabetic_report_card() { // TODO: Make sure to change the grade here after you finish the exercise. let report_card = ReportCard { - grade: 2.1, - student_name: "Gary Plotter".to_string(), + grade: 2.1, + student_name: "Gary Plotter".to_string(), student_age: 11, }; assert_eq!(report_card.print(), "Gary Plotter (11) - achieved a grade of A+"); } -} \ No newline at end of file +} diff --git a/exercises/primitive_types/primitive_types3.rs b/exercises/primitive_types/primitive_types3.rs index dfd6351c..aaa518be 100644 --- a/exercises/primitive_types/primitive_types3.rs +++ b/exercises/primitive_types/primitive_types3.rs @@ -1,5 +1,5 @@ // primitive_types3.rs -// Create an array with at least 100 elements in it where the ??? is. +// Create an array with at least 100 elements in it where the ??? is. // Execute `rustlings hint primitive_types3` for hints! // I AM NOT DONE diff --git a/exercises/structs/structs3.rs b/exercises/structs/structs3.rs index 5503ce15..883c803f 100644 --- a/exercises/structs/structs3.rs +++ b/exercises/structs/structs3.rs @@ -47,7 +47,7 @@ mod tests { fn create_international_package() { let sender_country = String::from("Spain"); let recipient_country = String::from("Russia"); - + let package = Package::new(sender_country, recipient_country, 1200); assert!(package.is_international()); @@ -59,9 +59,9 @@ mod tests { let recipient_country = String::from("Spain"); let cents_per_kg = ???; - + let package = Package::new(sender_country, recipient_country, 1500); - + assert_eq!(package.get_fees(cents_per_kg), 4500); } } diff --git a/exercises/traits/traits1.rs b/exercises/traits/traits1.rs index 8253ef80..2ef9e11b 100644 --- a/exercises/traits/traits1.rs +++ b/exercises/traits/traits1.rs @@ -1,21 +1,21 @@ // traits1.rs // Time to implement some traits! -// +// // Your task is to implement the trait // `AppendBar' for the type `String'. -// +// // The trait AppendBar has only one function, // which appends "Bar" to any object // implementing this trait. // I AM NOT DONE + trait AppendBar { fn append_bar(self) -> Self; } impl AppendBar for String { //Add your code here - } fn main() { @@ -40,5 +40,4 @@ mod tests { String::from("BarBar") ); } - -} \ No newline at end of file +} diff --git a/exercises/traits/traits2.rs b/exercises/traits/traits2.rs index 7f5014d0..b9a13a45 100644 --- a/exercises/traits/traits2.rs +++ b/exercises/traits/traits2.rs @@ -1,12 +1,12 @@ // traits2.rs -// +// // Your task is to implement the trait // `AppendBar' for a vector of strings. -// +// // To implement this trait, consider for // a moment what it means to 'append "Bar"' // to a vector of strings. -// +// // No boiler plate code this time, // you can do this! @@ -31,5 +31,4 @@ mod tests { assert_eq!(foo.pop().unwrap(), String::from("Bar")); assert_eq!(foo.pop().unwrap(), String::from("Foo")); } - } From c52be7dfcbfb99c40002f22efd32972915efebe1 Mon Sep 17 00:00:00 2001 From: Eli Blaney <5651165+eliblaney@users.noreply.github.com> Date: Sun, 12 Jul 2020 02:44:11 -0500 Subject: [PATCH 009/282] docs: Add uninstall info to README.md * docs: Add uninstall info to README.md * docs: Format commands as bash block --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index f1fc764c..47ac4b0e 100644 --- a/README.md +++ b/README.md @@ -101,6 +101,17 @@ rustlings hint myExercise1 After every couple of sections, there will be a quiz that'll test your knowledge on a bunch of sections at once. These quizzes are found in `exercises/quizN.rs`. +## Continuing On + +Once you've completed Rustlings, put your new knowledge to good use! Continue practicing your Rust skills by building your own projects, contributing to Rustlings, or finding other open-source projects to contribute to. + +If you'd like to uninstall Rustlings, you can do so by invoking cargo and removing the rustlings directory: + +```bash +cargo uninstall rustlings +rm -r rustlings/ # or on Windows: rmdir /s rustlings +``` + ## Completion Rustlings isn't done; there are a couple of sections that are very experimental and don't have proper documentation. These include: From 523d18b873a319f7c09262f44bd40e2fab1830e5 Mon Sep 17 00:00:00 2001 From: Chad Dougherty Date: Mon, 13 Jul 2020 05:39:05 -0400 Subject: [PATCH 010/282] feat(try_from_into): Add insufficient length test (#469) --- exercises/conversions/try_from_into.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/exercises/conversions/try_from_into.rs b/exercises/conversions/try_from_into.rs index dbdbe00e..9e452f28 100644 --- a/exercises/conversions/try_from_into.rs +++ b/exercises/conversions/try_from_into.rs @@ -127,4 +127,10 @@ mod tests { let v = vec![0, 0, 0, 0]; let _ = Color::try_from(&v[..]).unwrap(); } + #[test] + #[should_panic] + fn test_slice_insufficient_length() { + let v = vec![0, 0]; + let _ = Color::try_from(&v[..]).unwrap(); + } } From 4821a8be94af4f669042a06ab917934cfacd032f Mon Sep 17 00:00:00 2001 From: Ryan McQuen Date: Thu, 23 Jul 2020 10:20:21 -0700 Subject: [PATCH 011/282] feat: Add gitpod support (#473) --- .gitpod.yml | 7 +++++++ README.md | 6 ++++++ 2 files changed, 13 insertions(+) create mode 100644 .gitpod.yml diff --git a/.gitpod.yml b/.gitpod.yml new file mode 100644 index 00000000..46b1a6a8 --- /dev/null +++ b/.gitpod.yml @@ -0,0 +1,7 @@ +tasks: + - init: /workspace/rustlings/install.sh + command: /workspace/.cargo/bin/rustlings watch + +vscode: + extensions: + - rust-lang.rust@0.7.8:CvNqMTgDdt3UXt+6BCDTVg== diff --git a/README.md b/README.md index 47ac4b0e..7fba9d8c 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,12 @@ Start-BitsTransfer -Source https://git.io/rustlings-win -Destination $env:TMP/in To install Rustlings. Same as on MacOS/Linux, you will have access to the `rustlings` command after it. +## Browser: + +[Run on Repl.it](https://repl.it/github/rust-lang/rustlings) + +[Open in Gitpod](https://gitpod.io/#https://github.com/rust-lang/rustlings) + ## Manually Basically: Clone the repository, checkout to the latest tag, run `cargo install`. From 8f7b5bd00eb83542b959830ef55192d2d76db90a Mon Sep 17 00:00:00 2001 From: Ryan McQuen Date: Thu, 23 Jul 2020 10:21:15 -0700 Subject: [PATCH 012/282] feat: Add ability to run rustlings on repl.it (#471) Co-authored-by: fmoko --- .replit | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .replit diff --git a/.replit b/.replit new file mode 100644 index 00000000..8462a6fc --- /dev/null +++ b/.replit @@ -0,0 +1,2 @@ +language = "rust" +run = "[ -x ~/.cargo/bin/rustlings ] && ~/.cargo/bin/rustlings watch || ./install.sh" From 4f2468e14f574a93a2e9b688367b5752ed96ae7b Mon Sep 17 00:00:00 2001 From: Adi Vaknin Date: Thu, 23 Jul 2020 21:23:27 +0300 Subject: [PATCH 013/282] feat(cli): Added 'cls' command to 'watch' mode (#474) --- src/main.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index aa67aca6..0e1291c3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -143,15 +143,18 @@ fn main() { fn spawn_watch_shell(failed_exercise_hint: &Arc>>) { let failed_exercise_hint = Arc::clone(failed_exercise_hint); - println!("Type 'hint' to get help"); + println!("Type 'hint' to get help or 'clear' to clear the screen"); thread::spawn(move || loop { let mut input = String::new(); match io::stdin().read_line(&mut input) { Ok(_) => { - if input.trim().eq("hint") { + let input = input.trim(); + if input.eq("hint") { if let Some(hint) = &*failed_exercise_hint.lock().unwrap() { println!("{}", hint); } + } else if input.eq("clear") { + println!("\x1B[2J\x1B[1;1H"); } else { println!("unknown command: {}", input); } From 38a615f407f439158dccc0cb20d36ee70fe33c27 Mon Sep 17 00:00:00 2001 From: Robby Date: Fri, 24 Jul 2020 19:23:01 +0800 Subject: [PATCH 014/282] chore: add .vscode to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 6094e5c1..06de8710 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ target/ exercises/clippy/Cargo.toml exercises/clippy/Cargo.lock .idea +.vscode From 1cc40bc9ce95c23d56f6d91fa1c4deb646231fef Mon Sep 17 00:00:00 2001 From: Dany Marcoux Date: Mon, 3 Aug 2020 22:16:14 +0200 Subject: [PATCH 015/282] fix: Update rustlings version in Cargo.lock --- Cargo.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 52c8ed45..732a4b59 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -592,7 +592,7 @@ dependencies = [ [[package]] name = "rustlings" -version = "3.0.0" +version = "4.0.0" dependencies = [ "assert_cmd 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)", "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", From 9642f5a3f686270a4f8f6ba969919ddbbc4f7fdd Mon Sep 17 00:00:00 2001 From: Mukund Bhudia Date: Tue, 4 Aug 2020 12:57:01 +0100 Subject: [PATCH 016/282] feat: Added iterators1.rs exercise --- exercises/standard_library_types/README.md | 2 -- .../standard_library_types/iterators1.rs | 24 +++++++++++++++++++ info.toml | 21 ++++++++++++++++ 3 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 exercises/standard_library_types/iterators1.rs diff --git a/exercises/standard_library_types/README.md b/exercises/standard_library_types/README.md index 36b30c1f..8b53dd81 100644 --- a/exercises/standard_library_types/README.md +++ b/exercises/standard_library_types/README.md @@ -3,5 +3,3 @@ For the Box exercise check out the chapter [Using Box to Point to Data on the He For the Arc exercise check out the chapter [Shared-State Concurrency](https://doc.rust-lang.org/book/ch16-03-shared-state.html) of the Rust Book. For the Iterator exercise check out the chapters [Iterator](https://doc.rust-lang.org/book/ch13-02-iterators.html) of the Rust Book and the [Iterator documentation](https://doc.rust-lang.org/stable/std/iter/). -Do not adjust your monitors-- iterators1.rs is indeed missing. Iterators is a challenging topic, so we're leaving space for a simpler exercise! - diff --git a/exercises/standard_library_types/iterators1.rs b/exercises/standard_library_types/iterators1.rs new file mode 100644 index 00000000..3fd519d6 --- /dev/null +++ b/exercises/standard_library_types/iterators1.rs @@ -0,0 +1,24 @@ +// iterators1.rs +// +// Make me compile by filling in the `???`s +// +// When performing operations on elements within a collection, iterators are essential. +// This module helps you get familiar with the structure of using an iterator and +// how to go through elements within an iterable collection. +// +// Execute `rustlings hint iterators1` for hints :D + +// I AM NOT DONE + +fn main () { + let my_fav_fruits = vec!["banana", "custard apple", "avocado", "peach", "raspberry"]; + + let mut my_iterable_fav_fruits = ???; // TODO: Step 1 + + assert_eq!(my_iterable_fav_fruits.next(), Some(&"banana")); + assert_eq!(my_iterable_fav_fruits.next(), ???); // TODO: Step 2 + assert_eq!(my_iterable_fav_fruits.next(), Some(&"avocado")); + assert_eq!(my_iterable_fav_fruits.next(), ???); // TODO: Step 2.1 + assert_eq!(my_iterable_fav_fruits.next(), Some(&"raspberry")); + assert_eq!(my_iterable_fav_fruits.next(), ???); // TODO: Step 3 +} diff --git a/info.toml b/info.toml index 46e353ff..23f92bf5 100644 --- a/info.toml +++ b/info.toml @@ -644,6 +644,27 @@ inside the loop but still in the main thread. `child_numbers` should be a clone of the Arc of the numbers instead of a thread-local copy of the numbers.""" +[[exercises]] +name = "iterators1" +path = "exercises/standard_library_types/iterators1.rs" +mode = "compile" +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: +https://doc.rust-lang.org/std/vec/struct.Vec.html. + + +Step 2 & step 2.1: +Very similar to the lines above an below. You've got this! + + +Step 3: +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. +""" + [[exercises]] name = "iterators2" path = "exercises/standard_library_types/iterators2.rs" From 3144d3ae63963eae6bc8469a48dc0e586d77596d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20Barri=C3=A9?= Date: Mon, 10 Aug 2020 10:24:21 -0400 Subject: [PATCH 017/282] chore: Run rustfmt on exercises --- exercises/conversions/from_str.rs | 1 - exercises/conversions/try_from_into.rs | 2 +- exercises/conversions/using_as.rs | 4 +--- exercises/enums/enums2.rs | 4 ++-- exercises/enums/enums3.rs | 13 ++++++------- exercises/generics/generics1.rs | 1 - exercises/generics/generics2.rs | 2 +- exercises/generics/generics3.rs | 10 ++++++++-- exercises/macros/macros4.rs | 4 ++-- exercises/standard_library_types/box1.rs | 5 ++++- exercises/structs/structs3.rs | 6 +++++- exercises/traits/traits2.rs | 3 --- 12 files changed, 30 insertions(+), 25 deletions(-) diff --git a/exercises/conversions/from_str.rs b/exercises/conversions/from_str.rs index 014d0549..af9eee6d 100644 --- a/exercises/conversions/from_str.rs +++ b/exercises/conversions/from_str.rs @@ -82,5 +82,4 @@ mod tests { fn missing_name_and_invalid_age() { ",one".parse::().unwrap(); } - } diff --git a/exercises/conversions/try_from_into.rs b/exercises/conversions/try_from_into.rs index 9e452f28..b830c166 100644 --- a/exercises/conversions/try_from_into.rs +++ b/exercises/conversions/try_from_into.rs @@ -2,7 +2,7 @@ // Basically, this is the same as From. The main difference is that this should return a Result type // instead of the target type itself. // You can read more about it at https://doc.rust-lang.org/std/convert/trait.TryFrom.html -use std::convert::{TryInto, TryFrom}; +use std::convert::{TryFrom, TryInto}; #[derive(Debug)] struct Color { diff --git a/exercises/conversions/using_as.rs b/exercises/conversions/using_as.rs index 922abae0..b3c197f8 100644 --- a/exercises/conversions/using_as.rs +++ b/exercises/conversions/using_as.rs @@ -7,9 +7,7 @@ // I AM NOT DONE fn average(values: &[f64]) -> f64 { - let total = values - .iter() - .fold(0.0, |a, b| a + b); + let total = values.iter().fold(0.0, |a, b| a + b); total / values.len() } diff --git a/exercises/enums/enums2.rs b/exercises/enums/enums2.rs index 52ccb221..ec32d952 100644 --- a/exercises/enums/enums2.rs +++ b/exercises/enums/enums2.rs @@ -16,10 +16,10 @@ impl Message { fn main() { let messages = [ - Message::Move{ x: 10, y: 30 }, + Message::Move { x: 10, y: 30 }, Message::Echo(String::from("hello world")), Message::ChangeColor(200, 255, 255), - Message::Quit + Message::Quit, ]; for message in &messages { diff --git a/exercises/enums/enums3.rs b/exercises/enums/enums3.rs index e9621b8e..178b40c4 100644 --- a/exercises/enums/enums3.rs +++ b/exercises/enums/enums3.rs @@ -9,13 +9,13 @@ enum Message { struct Point { x: u8, - y: u8 + y: u8, } struct State { color: (u8, u8, u8), position: Point, - quit: bool + quit: bool, } impl State { @@ -46,14 +46,14 @@ mod tests { #[test] fn test_match_message_call() { - let mut state = State{ + let mut state = State { quit: false, - position: Point{ x: 0, y: 0 }, - color: (0, 0, 0) + position: Point { x: 0, y: 0 }, + color: (0, 0, 0), }; state.process(Message::ChangeColor((255, 0, 255))); state.process(Message::Echo(String::from("hello world"))); - state.process(Message::Move(Point{ x: 10, y: 15 })); + state.process(Message::Move(Point { x: 10, y: 15 })); state.process(Message::Quit); assert_eq!(state.color, (255, 0, 255)); @@ -61,5 +61,4 @@ mod tests { assert_eq!(state.position.y, 15); assert_eq!(state.quit, true); } - } diff --git a/exercises/generics/generics1.rs b/exercises/generics/generics1.rs index 1e6ae9d7..967287ef 100644 --- a/exercises/generics/generics1.rs +++ b/exercises/generics/generics1.rs @@ -7,4 +7,3 @@ fn main() { let mut shopping_list: Vec = Vec::new(); shopping_list.push("milk"); } - diff --git a/exercises/generics/generics2.rs b/exercises/generics/generics2.rs index 20c21279..0cb59adc 100644 --- a/exercises/generics/generics2.rs +++ b/exercises/generics/generics2.rs @@ -4,7 +4,7 @@ // I AM NOT DONE struct Wrapper { - value: u32 + value: u32, } impl Wrapper { diff --git a/exercises/generics/generics3.rs b/exercises/generics/generics3.rs index 760028ed..5c745e25 100644 --- a/exercises/generics/generics3.rs +++ b/exercises/generics/generics3.rs @@ -33,7 +33,10 @@ mod tests { student_name: "Tom Wriggle".to_string(), student_age: 12, }; - assert_eq!(report_card.print(), "Tom Wriggle (12) - achieved a grade of 2.1"); + assert_eq!( + report_card.print(), + "Tom Wriggle (12) - achieved a grade of 2.1" + ); } #[test] @@ -44,6 +47,9 @@ mod tests { student_name: "Gary Plotter".to_string(), student_age: 11, }; - assert_eq!(report_card.print(), "Gary Plotter (11) - achieved a grade of A+"); + assert_eq!( + report_card.print(), + "Gary Plotter (11) - achieved a grade of A+" + ); } } diff --git a/exercises/macros/macros4.rs b/exercises/macros/macros4.rs index 3a748078..1b550f43 100644 --- a/exercises/macros/macros4.rs +++ b/exercises/macros/macros4.rs @@ -6,10 +6,10 @@ macro_rules! my_macro { () => { println!("Check out my macro!"); - } + }; ($val:expr) => { println!("Look at this other macro: {}", $val); - } + }; } fn main() { diff --git a/exercises/standard_library_types/box1.rs b/exercises/standard_library_types/box1.rs index f2654ce2..f312f3d6 100644 --- a/exercises/standard_library_types/box1.rs +++ b/exercises/standard_library_types/box1.rs @@ -26,7 +26,10 @@ pub enum List { fn main() { println!("This is an empty cons list: {:?}", create_empty_list()); - println!("This is a non-empty cons list: {:?}", create_non_empty_list()); + println!( + "This is a non-empty cons list: {:?}", + create_non_empty_list() + ); } pub fn create_empty_list() -> List { diff --git a/exercises/structs/structs3.rs b/exercises/structs/structs3.rs index 883c803f..36d46e90 100644 --- a/exercises/structs/structs3.rs +++ b/exercises/structs/structs3.rs @@ -17,7 +17,11 @@ impl Package { if weight_in_grams <= 0 { // Something goes here... } else { - return Package {sender_country, recipient_country, weight_in_grams}; + return Package { + sender_country, + recipient_country, + weight_in_grams, + }; } } diff --git a/exercises/traits/traits2.rs b/exercises/traits/traits2.rs index b9a13a45..916c3c4b 100644 --- a/exercises/traits/traits2.rs +++ b/exercises/traits/traits2.rs @@ -18,9 +18,6 @@ trait AppendBar { //TODO: Add your code here - - - #[cfg(test)] mod tests { use super::*; From 81f8c2f83c6bb5c239fd2e0cf856d1535692af3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20Barri=C3=A9?= Date: Mon, 10 Aug 2020 10:42:54 -0400 Subject: [PATCH 018/282] chore: Run cargo fmt --- src/exercise.rs | 5 +++-- src/main.rs | 4 +--- src/verify.rs | 6 ++---- tests/integration_tests.rs | 2 +- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/exercise.rs b/src/exercise.rs index 2108d81e..e70538bb 100644 --- a/src/exercise.rs +++ b/src/exercise.rs @@ -167,9 +167,10 @@ path = "{}.rs""#, fn run(&self) -> Result { let arg = match self.mode { Mode::Test => "--show-output", - _ => "" + _ => "", }; - let cmd = Command::new(&temp_file()).arg(arg) + let cmd = Command::new(&temp_file()) + .arg(arg) .output() .expect("Failed to run 'run' command"); diff --git a/src/main.rs b/src/main.rs index 0e1291c3..b5814bfb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -126,9 +126,7 @@ fn main() { ); println!(); println!("We hope you enjoyed learning about the various aspects of Rust!"); - println!( - "If you noticed any issues, please don't hesitate to report them to our repo." - ); + println!("If you noticed any issues, please don't hesitate to report them to our repo."); println!("You can also contribute your own exercises to help the greater community!"); println!(); println!("Before reporting an issue or contributing, please read our guidelines:"); diff --git a/src/verify.rs b/src/verify.rs index 807bea9e..00e45c8c 100644 --- a/src/verify.rs +++ b/src/verify.rs @@ -9,7 +9,7 @@ use indicatif::ProgressBar; // determines whether or not the test harness outputs are displayed. pub fn verify<'a>( start_at: impl IntoIterator, - verbose: bool + verbose: bool, ) -> Result<(), &'a Exercise> { for exercise in start_at { let compile_result = match exercise.mode { @@ -77,9 +77,7 @@ fn compile_and_run_interactively(exercise: &Exercise) -> Result { // Compile the given Exercise as a test harness and display // the output if verbose is set to true -fn compile_and_test( - exercise: &Exercise, run_mode: RunMode, verbose: bool -) -> Result { +fn compile_and_test(exercise: &Exercise, run_mode: RunMode, verbose: bool) -> Result { let progress_bar = ProgressBar::new_spinner(); progress_bar.set_message(format!("Testing {}...", exercise).as_str()); progress_bar.enable_steady_tick(100); diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs index 0f49b5a8..2baf9b86 100644 --- a/tests/integration_tests.rs +++ b/tests/integration_tests.rs @@ -180,4 +180,4 @@ fn run_single_test_success_without_output() { .assert() .code(0) .stdout(predicates::str::contains("THIS TEST TOO SHALL PAS").not()); -} \ No newline at end of file +} From b4062ef6993e80dac107c4093ea85166ad3ee0fa Mon Sep 17 00:00:00 2001 From: seeplusplus Date: Sun, 16 Aug 2020 20:55:50 -0400 Subject: [PATCH 019/282] fix(arc1): index mod should equal thread count --- exercises/standard_library_types/arc1.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/standard_library_types/arc1.rs b/exercises/standard_library_types/arc1.rs index 07932c63..4ad649f1 100644 --- a/exercises/standard_library_types/arc1.rs +++ b/exercises/standard_library_types/arc1.rs @@ -21,7 +21,7 @@ fn main() { let mut sum = 0; while i < child_numbers.len() { sum += child_numbers[i]; - i += 5; + i += 8; } println!("Sum of offset {} is {}", offset, sum); })); From dd54ccf6777873b75e01ad6fbcf247c7de21994d Mon Sep 17 00:00:00 2001 From: John Heath <6026956+CaribouJohn@users.noreply.github.com> Date: Mon, 24 Aug 2020 22:37:31 +0100 Subject: [PATCH 020/282] Make comments on example clearer I actually struggled because I overlooked the fact that I needed to change the 2.1 to "A+". So I wanted to make things clearer for future rustlings. --- exercises/generics/generics3.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/exercises/generics/generics3.rs b/exercises/generics/generics3.rs index 5c745e25..6f951450 100644 --- a/exercises/generics/generics3.rs +++ b/exercises/generics/generics3.rs @@ -4,8 +4,11 @@ // However, the school also issues alphabetical grades (A+ -> F-) and needs // to be able to print both types of report card! -// Make the necessary code changes to support alphabetical report cards, thereby making -// the second test pass. +// Make the necessary code changes in the struct ReportCard and the impl block +// to support alphabetical report cards. Change the Grade in the second test to "A+" +// to show that your changes allow alphabetical grades. + +// Execute 'rustlings hint generics3' for hints! // I AM NOT DONE From 101072ab9f8c80b40b8b88cb06cbe38aca2481c5 Mon Sep 17 00:00:00 2001 From: Antoine Barthelemy Date: Tue, 25 Aug 2020 16:38:41 +0200 Subject: [PATCH 021/282] fix(exercises): adding question mark to quiz2 Question marks added for consistency. closes #496 --- exercises/quiz2.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/exercises/quiz2.rs b/exercises/quiz2.rs index 8caeaa99..de0dce95 100644 --- a/exercises/quiz2.rs +++ b/exercises/quiz2.rs @@ -17,14 +17,14 @@ fn string(arg: String) { } fn main() { - ("blue"); - ("red".to_string()); - (String::from("hi")); - ("rust is fun!".to_owned()); - ("nice weather".into()); - (format!("Interpolation {}", "Station")); - (&String::from("abc")[0..1]); - (" hello there ".trim()); - ("Happy Monday!".to_string().replace("Mon", "Tues")); - ("mY sHiFt KeY iS sTiCkY".to_lowercase()); + ???("blue"); + ???("red".to_string()); + ???(String::from("hi")); + ???("rust is fun!".to_owned()); + ???("nice weather".into()); + ???(format!("Interpolation {}", "Station")); + ???(&String::from("abc")[0..1]); + ???(" hello there ".trim()); + ???("Happy Monday!".to_string().replace("Mon", "Tues")); + ???("mY sHiFt KeY iS sTiCkY".to_lowercase()); } From 6bb0b48b100fe4af5bddbcf639e8843350b62555 Mon Sep 17 00:00:00 2001 From: Samuel Batista <47303296+bhgsbatista@users.noreply.github.com> Date: Wed, 26 Aug 2020 22:17:03 -0400 Subject: [PATCH 022/282] Make macros4 not compile by default Did you mean this? I'm new to rust and this test passed right away, so unsure what the intention was. --- exercises/macros/macros4.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exercises/macros/macros4.rs b/exercises/macros/macros4.rs index 1b550f43..3a748078 100644 --- a/exercises/macros/macros4.rs +++ b/exercises/macros/macros4.rs @@ -6,10 +6,10 @@ macro_rules! my_macro { () => { println!("Check out my macro!"); - }; + } ($val:expr) => { println!("Look at this other macro: {}", $val); - }; + } } fn main() { From ee7cdc66b31673c0fb02de0ce732812f855e69e8 Mon Sep 17 00:00:00 2001 From: Koalab99 <60042855+Koalab99@users.noreply.github.com> Date: Thu, 27 Aug 2020 19:51:19 +0200 Subject: [PATCH 023/282] chore: Removed extra whitespaces Co-authored-by: Corentin ARNOULD --- CHANGELOG.md | 4 ++-- exercises/enums/README.md | 4 ++-- exercises/error_handling/README.md | 4 ++-- exercises/generics/generics3.rs | 4 ++-- exercises/traits/README.md | 6 +++--- info.toml | 26 +++++++++++++------------- install.ps1 | 2 +- 7 files changed, 25 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d984eb6..a96df52c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -83,14 +83,14 @@ * Update deps to version compatable with aarch64-pc-windows (#263) ([19a93428](https://github.com/rust-lang/rustlings/commit/19a93428b3c73d994292671f829bdc8e5b7b3401)) * **docs:** * Added a necessary step to Windows installation process (#242) ([3906efcd](https://github.com/rust-lang/rustlings/commit/3906efcd52a004047b460ed548037093de3f523f)) - * Fixed mangled sentence from book; edited for clarity (#266) ([ade52ff](https://github.com/rust-lang/rustlings/commit/ade52ffb739987287ddd5705944c8777705faed9)) + * Fixed mangled sentence from book; edited for clarity (#266) ([ade52ff](https://github.com/rust-lang/rustlings/commit/ade52ffb739987287ddd5705944c8777705faed9)) * Updated iterators readme to account for iterators4 exercise (#273) ([bec8e3a](https://github.com/rust-lang/rustlings/commit/bec8e3a644cbd88db1c73ea5f1d8a364f4a34016)) * **installation:** make fatal errors more obvious (#272) ([17d0951e](https://github.com/rust-lang/rustlings/commit/17d0951e66fda8e11b204d5c4c41a0d5e22e78f7)) * **iterators2:** * Remove reference to missing iterators2.rs (#245) ([419f7797](https://github.com/rust-lang/rustlings/commit/419f7797f294e4ce6a2b883199731b5bde77d262)) * **as_ref_mut:** Enable a test and improve per clippy's suggestion (#256) ([dfdf809](https://github.com/rust-lang/rustlings/commit/dfdf8093ebbd4145864995627b812780de52f902)) * **tests1:** - * Change test command ([fe10e06c](https://github.com/rust-lang/rustlings/commit/fe10e06c3733ddb4a21e90d09bf79bfe618e97ce) + * Change test command ([fe10e06c](https://github.com/rust-lang/rustlings/commit/fe10e06c3733ddb4a21e90d09bf79bfe618e97ce) * Correct test command in tests1.rs comment (#263) ([39fa7ae](https://github.com/rust-lang/rustlings/commit/39fa7ae8b70ad468da49b06f11b2383135a63bcf)) #### Features diff --git a/exercises/enums/README.md b/exercises/enums/README.md index a090a43e..091f5d04 100644 --- a/exercises/enums/README.md +++ b/exercises/enums/README.md @@ -1,8 +1,8 @@ ### Enums -Rust allows you to define types called "enums" which enumerate possible values. +Rust allows you to define types called "enums" which enumerate possible values. Enums are a feature in many languages, but their capabilities differ in each language. Rust’s enums are most similar to algebraic data types in functional languages, such as F#, OCaml, and Haskell. -Useful in combination with enums is Rust's "pattern matching" facility, which makes it easy to run different code for different values of an enumeration. +Useful in combination with enums is Rust's "pattern matching" facility, which makes it easy to run different code for different values of an enumeration. #### Book Sections diff --git a/exercises/error_handling/README.md b/exercises/error_handling/README.md index cf66c2be..77a58d18 100644 --- a/exercises/error_handling/README.md +++ b/exercises/error_handling/README.md @@ -1,5 +1,5 @@ For this exercise check out the sections: -- [Error Handling](https://doc.rust-lang.org/book/ch09-02-recoverable-errors-with-result.html) -- [Generics](https://doc.rust-lang.org/book/ch10-01-syntax.html) +- [Error Handling](https://doc.rust-lang.org/book/ch09-02-recoverable-errors-with-result.html) +- [Generics](https://doc.rust-lang.org/book/ch10-01-syntax.html) of the Rust Book. diff --git a/exercises/generics/generics3.rs b/exercises/generics/generics3.rs index 6f951450..64dd9bc1 100644 --- a/exercises/generics/generics3.rs +++ b/exercises/generics/generics3.rs @@ -4,8 +4,8 @@ // However, the school also issues alphabetical grades (A+ -> F-) and needs // to be able to print both types of report card! -// Make the necessary code changes in the struct ReportCard and the impl block -// to support alphabetical report cards. Change the Grade in the second test to "A+" +// Make the necessary code changes in the struct ReportCard and the impl block +// to support alphabetical report cards. Change the Grade in the second test to "A+" // to show that your changes allow alphabetical grades. // Execute 'rustlings hint generics3' for hints! diff --git a/exercises/traits/README.md b/exercises/traits/README.md index 1ce46fe0..8cd03ec4 100644 --- a/exercises/traits/README.md +++ b/exercises/traits/README.md @@ -1,6 +1,6 @@ ### Traits -A trait is a collection of methods. +A trait is a collection of methods. Data types can implement traits. To do so, the methods making up the trait are defined for the data type. For example, the `String` data type implements the `From<&str>` trait. This allows a user to write `String::from("hello")`. @@ -8,7 +8,7 @@ In this way, traits are somewhat similar to Java interfaces and C++ abstract cla Some additional common Rust traits include: -+ `Clone` (the `clone` method), ++ `Clone` (the `clone` method), + `Display` (which allows formatted display via `{}`), and + `Debug` (which allows formatted display via `{:?}`). @@ -17,4 +17,4 @@ Because traits indicate shared behavior between data types, they are useful when #### Book Sections -- [Traits](https://doc.rust-lang.org/book/ch10-02-traits.html) \ No newline at end of file +- [Traits](https://doc.rust-lang.org/book/ch10-02-traits.html) diff --git a/info.toml b/info.toml index 46e353ff..a64509e2 100644 --- a/info.toml +++ b/info.toml @@ -52,7 +52,7 @@ because we want to assign a different typed value to an existing variable. Somet 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.""" @@ -61,13 +61,13 @@ name = "variables6" path = "exercises/variables/variables6.rs" 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 +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 types must also always be annotated. -Read more about constants under 'Differences Between Variables and Constants' in the book's section 'Variables and Mutability': +Read more about constants under 'Differences Between Variables and Constants' in the book's section 'Variables and Mutability': https://doc.rust-lang.org/book/ch03-01-variables-and-mutability.html#differences-between-variables-and-constants """ @@ -237,8 +237,8 @@ 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. -There is however some shortcuts that can be taken when instantiating structs. +Creating instances of structs is easy, all you need to do is assign some values to its fields. +There is 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""" [[exercises]] @@ -682,8 +682,8 @@ name = "iterators4" path = "exercises/standard_library_types/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 +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.""" @@ -703,10 +703,10 @@ 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. -Vectors provide suitable methods for adding an element at the end. See +Vectors provide suitable methods for adding an element at the end. See the documentation at: https://doc.rust-lang.org/std/vec/struct.Vec.html""" # Generics @@ -724,7 +724,7 @@ 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 @@ -735,7 +735,7 @@ name = "generics3" path = "exercises/generics/generics3.rs" mode = "test" hint = """ -To find the best solution to this challenge you're going to need to think back to your +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;" This is definitely harder than the last two exercises! You need to think about not only making the diff --git a/install.ps1 b/install.ps1 index 6504e69e..f7472ad1 100644 --- a/install.ps1 +++ b/install.ps1 @@ -35,7 +35,7 @@ if (Get-Command cargo -ErrorAction SilentlyContinue) { function vercomp($v1, $v2) { if ($v1 -eq $v2) { return 0 - } + } $v1 = $v1.Replace(".", "0") $v2 = $v2.Replace(".", "0") From 3286c5ec19ea5fb7ded81d047da5f8594108a490 Mon Sep 17 00:00:00 2001 From: Ryan McQuen Date: Mon, 7 Sep 2020 10:09:27 -0700 Subject: [PATCH 024/282] fix(using_as): Add test so that proper type is returned. (#512) --- exercises/conversions/using_as.rs | 11 +++++++++++ info.toml | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/exercises/conversions/using_as.rs b/exercises/conversions/using_as.rs index b3c197f8..821309ec 100644 --- a/exercises/conversions/using_as.rs +++ b/exercises/conversions/using_as.rs @@ -3,6 +3,7 @@ // It also helps with renaming imports. // // The goal is to make sure that the division does not fail to compile +// and returns the proper type. // I AM NOT DONE @@ -15,3 +16,13 @@ fn main() { let values = [3.5, 0.3, 13.0, 11.7]; println!("{}", average(&values)); } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn returns_proper_type_and_value() { + assert_eq!(average(&[3.5, 0.3, 13.0, 11.7]), 7.125); + } +} diff --git a/info.toml b/info.toml index a64509e2..2e90f138 100644 --- a/info.toml +++ b/info.toml @@ -787,7 +787,7 @@ what you've learned :)""" [[exercises]] name = "using_as" path = "exercises/conversions/using_as.rs" -mode = "compile" +mode = "test" hint = """ Use the `as` operator to cast one of the operands in the last line of the `average` function into the expected return type.""" From 8ff5fde88edb8f24253d7dc894501473cf701dbc Mon Sep 17 00:00:00 2001 From: Mukund Bhudia Date: Fri, 18 Sep 2020 10:40:11 +0100 Subject: [PATCH 025/282] Update info.toml for typo fix Co-authored-by: Andrew Marquez --- info.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/info.toml b/info.toml index 23f92bf5..d800720b 100644 --- a/info.toml +++ b/info.toml @@ -656,7 +656,7 @@ https://doc.rust-lang.org/std/vec/struct.Vec.html. Step 2 & step 2.1: -Very similar to the lines above an below. You've got this! +Very similar to the lines above and below. You've got this! Step 3: From 114b54cbdb977234b39e5f180d937c14c78bb8b2 Mon Sep 17 00:00:00 2001 From: Jannek Squar Date: Sat, 19 Sep 2020 21:22:56 +0200 Subject: [PATCH 026/282] fix(structs3): Small adjustment of variable name Co-authored-by: Jannek --- exercises/structs/structs3.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/exercises/structs/structs3.rs b/exercises/structs/structs3.rs index 36d46e90..06fcaf29 100644 --- a/exercises/structs/structs3.rs +++ b/exercises/structs/structs3.rs @@ -29,8 +29,8 @@ impl Package { // Something goes here... } - fn get_fees(&self, cents_per_kg: i32) -> ??? { - // Something goes here... (beware of grams to kg conversion) + fn get_fees(&self, cents_per_gram: i32) -> ??? { + // Something goes here... } } @@ -62,10 +62,10 @@ mod tests { let sender_country = String::from("Spain"); let recipient_country = String::from("Spain"); - let cents_per_kg = ???; + let cents_per_gram = ???; let package = Package::new(sender_country, recipient_country, 1500); - assert_eq!(package.get_fees(cents_per_kg), 4500); + assert_eq!(package.get_fees(cents_per_gram), 4500); } } From bec97b6c76bea09d3a326bb94f9375a5698095e6 Mon Sep 17 00:00:00 2001 From: Calvin Brown Date: Mon, 21 Sep 2020 15:23:19 -0500 Subject: [PATCH 027/282] Fixing test3 to have enough tests to make sure we test all cases --- exercises/tests/tests3.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/exercises/tests/tests3.rs b/exercises/tests/tests3.rs index 693b8aa5..06cf7ea7 100644 --- a/exercises/tests/tests3.rs +++ b/exercises/tests/tests3.rs @@ -18,4 +18,9 @@ mod tests { fn is_true_when_even() { assert!(); } + + #[test] + fn is_false_when_even() { + assert!(); + } } From 114cc2db21efed01e3779225751bdc5e2db4ad5a Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Tue, 22 Sep 2020 08:36:52 +0000 Subject: [PATCH 028/282] docs: update README.md [skip ci] --- README.md | 93 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 48 insertions(+), 45 deletions(-) diff --git a/README.md b/README.md index 7fba9d8c..8ad71e62 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ![crab pet](https://i.imgur.com/LbZJgmm.gif) -[![All Contributors](https://img.shields.io/badge/all_contributors-48-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-49-orange.svg?style=flat-square)](#contributors-) # rustlings πŸ¦€β€οΈ [![Build status](https://badge.buildkite.com/7af93d81dc522c67a1ec8e33ff5705861b1cb36360b774807f.svg)](https://buildkite.com/mokou/rustlings) @@ -149,64 +149,67 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d - - + + - - - - - + + + + + - - - - - - - - + + + + + + + + - - - - - - - + + + + + + + - - + + - - - - - + + + + + - - - - - - + + + + + + - + - - - - - - - - + + + + + + + + + + +

Carol (Nichols || Goulding)

πŸ’» πŸ–‹

QuietMisdreavus

πŸ’» πŸ–‹

Carol (Nichols || Goulding)

πŸ’» πŸ–‹

QuietMisdreavus

πŸ’» πŸ–‹

Robert M Lugg

πŸ–‹

Hynek Schlawack

πŸ’»

Katharina Fey

πŸ’»

lukabavdaz

πŸ’» πŸ–‹

Erik Vesteraas

πŸ’»

delet0r

πŸ’»

Hynek Schlawack

πŸ’»

Katharina Fey

πŸ’»

lukabavdaz

πŸ’» πŸ–‹

Erik Vesteraas

πŸ’»

delet0r

πŸ’»

Shaun Bennett

πŸ’»

Andrew Bagshaw

πŸ’»

Kyle Isom

πŸ’»

Colin Pitrat

πŸ’»

Zac Anger

πŸ’»

Matthias Geier

πŸ’»

Chris Pearce

πŸ’»

Yvan Sraka

πŸ’»

Shaun Bennett

πŸ’»

Andrew Bagshaw

πŸ’»

Kyle Isom

πŸ’»

Colin Pitrat

πŸ’»

Zac Anger

πŸ’»

Matthias Geier

πŸ’»

Chris Pearce

πŸ’»

Yvan Sraka

πŸ’»

Denys Smirnov

πŸ’»

eddyp

πŸ’»

Brian Kung

πŸ’» πŸ–‹

Russell

πŸ’»

Dan Wilhelm

πŸ“–

Jesse

πŸ’» πŸ–‹

Fredrik JambrΓ©n

πŸ’»

Denys Smirnov

πŸ’»

eddyp

πŸ’»

Brian Kung

πŸ’» πŸ–‹

Russell

πŸ’»

Dan Wilhelm

πŸ“–

Jesse

πŸ’» πŸ–‹

Fredrik JambrΓ©n

πŸ’»

Pete McFarlane

πŸ–‹

nkanderson

πŸ’» πŸ–‹

Ajax M

πŸ“–

nkanderson

πŸ’» πŸ–‹

Ajax M

πŸ“–

Dylan Nugent

πŸ–‹

vyaslav

πŸ’» πŸ–‹

George

πŸ’»

Thomas Holloway

πŸ’» πŸ–‹

Jubilee

πŸ’»

WofWca

πŸ’»

vyaslav

πŸ’» πŸ–‹

George

πŸ’»

Thomas Holloway

πŸ’» πŸ–‹

Jubilee

πŸ’»

WofWca

πŸ’»

Roberto Vidal

πŸ’» πŸ“– πŸ€” 🚧

Jens

πŸ“–

Rahat Ahmed

πŸ“–

Abdou Seck

πŸ’» πŸ–‹ πŸ‘€

Katie

πŸ’»

Socrates

πŸ“–

Roberto Vidal

πŸ’» πŸ“– πŸ€” 🚧

Jens

πŸ“–

Rahat Ahmed

πŸ“–

Abdou Seck

πŸ’» πŸ–‹ πŸ‘€

Katie

πŸ’»

Socrates

πŸ“–

gnodarse

πŸ–‹

Harrison Metzger

πŸ’»

Harrison Metzger

πŸ’»

Torben Jonas

πŸ’» πŸ–‹

Paul Bissex

πŸ“–

Steven Mann

πŸ’» πŸ–‹

Mario Reder

πŸ’» πŸ–‹

skim

πŸ’»

Sanjay K

πŸ’» πŸ–‹

Rohan Jain

πŸ’»

Said Aspen

πŸ’» πŸ–‹

Torben Jonas

πŸ’» πŸ–‹

Paul Bissex

πŸ“–

Steven Mann

πŸ’» πŸ–‹

Mario Reder

πŸ’» πŸ–‹

skim

πŸ’»

Sanjay K

πŸ’» πŸ–‹

Rohan Jain

πŸ’»

Said Aspen

πŸ’» πŸ–‹

Ufuk Celebi

πŸ’»
From 8f8a85303b60f111a4605a5bc77259b89c81c2f7 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Tue, 22 Sep 2020 08:36:53 +0000 Subject: [PATCH 029/282] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index d4a0857d..12d21d7d 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -454,11 +454,20 @@ "code", "content" ] + }, + { + "login": "uce", + "name": "Ufuk Celebi", + "avatar_url": "https://avatars3.githubusercontent.com/u/1756620?v=4", + "profile": "https://github.com/uce", + "contributions": [ + "code" + ] } ], "contributorsPerLine": 8, "projectName": "rustlings", - "projectOwner": "fmoko", + "projectOwner": "rust-lang", "repoType": "github", "repoHost": "https://github.com", "skipCi": true From f5cb439fe61da52386d85e678ef6f3be507be546 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Tue, 22 Sep 2020 08:38:59 +0000 Subject: [PATCH 030/282] docs: update README.md [skip ci] --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8ad71e62..83fdf978 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ![crab pet](https://i.imgur.com/LbZJgmm.gif) -[![All Contributors](https://img.shields.io/badge/all_contributors-49-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-50-orange.svg?style=flat-square)](#contributors-) # rustlings πŸ¦€β€οΈ [![Build status](https://badge.buildkite.com/7af93d81dc522c67a1ec8e33ff5705861b1cb36360b774807f.svg)](https://buildkite.com/mokou/rustlings) @@ -210,6 +210,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Ufuk Celebi

πŸ’» +
lebedevsergey

πŸ“– From 6480fcaf7c89922c5a3ff1ad091ba0305c4d7404 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Tue, 22 Sep 2020 08:39:00 +0000 Subject: [PATCH 031/282] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 12d21d7d..e1d48a1c 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -463,6 +463,15 @@ "contributions": [ "code" ] + }, + { + "login": "lebedevsergey", + "name": "lebedevsergey", + "avatar_url": "https://avatars2.githubusercontent.com/u/7325764?v=4", + "profile": "https://github.com/lebedevsergey", + "contributions": [ + "doc" + ] } ], "contributorsPerLine": 8, From 77f407dd5ff6a3585f9b0236450f8429ca94efbd Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Tue, 22 Sep 2020 08:40:45 +0000 Subject: [PATCH 032/282] docs: update README.md [skip ci] --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 83fdf978..522b6c4a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ![crab pet](https://i.imgur.com/LbZJgmm.gif) -[![All Contributors](https://img.shields.io/badge/all_contributors-50-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-51-orange.svg?style=flat-square)](#contributors-) # rustlings πŸ¦€β€οΈ [![Build status](https://badge.buildkite.com/7af93d81dc522c67a1ec8e33ff5705861b1cb36360b774807f.svg)](https://buildkite.com/mokou/rustlings) @@ -211,6 +211,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Ufuk Celebi

πŸ’»
lebedevsergey

πŸ“– +
Aleksei Trifonov

πŸ–‹ From 98d6b15fc0e5480c6ddd8ffa125976131b3448e4 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Tue, 22 Sep 2020 08:40:46 +0000 Subject: [PATCH 033/282] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index e1d48a1c..91c9b8e1 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -472,6 +472,15 @@ "contributions": [ "doc" ] + }, + { + "login": "avrong", + "name": "Aleksei Trifonov", + "avatar_url": "https://avatars2.githubusercontent.com/u/6342851?v=4", + "profile": "https://github.com/avrong", + "contributions": [ + "content" + ] } ], "contributorsPerLine": 8, From b6dd1af7d2d610dad159b114532fa42f2f19415f Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Tue, 22 Sep 2020 08:43:23 +0000 Subject: [PATCH 034/282] docs: update README.md [skip ci] --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 522b6c4a..dbf5fba4 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ![crab pet](https://i.imgur.com/LbZJgmm.gif) -[![All Contributors](https://img.shields.io/badge/all_contributors-51-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-52-orange.svg?style=flat-square)](#contributors-) # rustlings πŸ¦€β€οΈ [![Build status](https://badge.buildkite.com/7af93d81dc522c67a1ec8e33ff5705861b1cb36360b774807f.svg)](https://buildkite.com/mokou/rustlings) @@ -212,6 +212,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Ufuk Celebi

πŸ’»
lebedevsergey

πŸ“–
Aleksei Trifonov

πŸ–‹ +
Darren Meehan

πŸ–‹ From 18b2d451cd5b2f28a06cd7bf6cc6aea2c293a4af Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Tue, 22 Sep 2020 08:43:24 +0000 Subject: [PATCH 035/282] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 91c9b8e1..3cc7fb61 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -481,6 +481,15 @@ "contributions": [ "content" ] + }, + { + "login": "Darrenmeehan", + "name": "Darren Meehan", + "avatar_url": "https://avatars2.githubusercontent.com/u/411136?v=4", + "profile": "https://drn.ie", + "contributions": [ + "content" + ] } ], "contributorsPerLine": 8, From f285ac22815550e77894ee523b2129c36b31da9b Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Tue, 22 Sep 2020 08:44:56 +0000 Subject: [PATCH 036/282] docs: update README.md [skip ci] --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index dbf5fba4..dd205688 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ![crab pet](https://i.imgur.com/LbZJgmm.gif) -[![All Contributors](https://img.shields.io/badge/all_contributors-52-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-53-orange.svg?style=flat-square)](#contributors-) # rustlings πŸ¦€β€οΈ [![Build status](https://badge.buildkite.com/7af93d81dc522c67a1ec8e33ff5705861b1cb36360b774807f.svg)](https://buildkite.com/mokou/rustlings) @@ -213,6 +213,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
lebedevsergey

πŸ“–
Aleksei Trifonov

πŸ–‹
Darren Meehan

πŸ–‹ +
Jihchi Lee

πŸ–‹ From ca4f02607404edd380d8c565d6b7b6c611cea94a Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Tue, 22 Sep 2020 08:44:57 +0000 Subject: [PATCH 037/282] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 3cc7fb61..a0a56af4 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -490,6 +490,15 @@ "contributions": [ "content" ] + }, + { + "login": "jihchi", + "name": "Jihchi Lee", + "avatar_url": "https://avatars1.githubusercontent.com/u/87983?v=4", + "profile": "https://github.com/jihchi", + "contributions": [ + "content" + ] } ], "contributorsPerLine": 8, From 062f18d3538c5a493d64a7a884f06be4ca6ffde5 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Tue, 22 Sep 2020 08:48:38 +0000 Subject: [PATCH 038/282] docs: update README.md [skip ci] --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index dd205688..96ad84e5 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ![crab pet](https://i.imgur.com/LbZJgmm.gif) -[![All Contributors](https://img.shields.io/badge/all_contributors-53-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-54-orange.svg?style=flat-square)](#contributors-) # rustlings πŸ¦€β€οΈ [![Build status](https://badge.buildkite.com/7af93d81dc522c67a1ec8e33ff5705861b1cb36360b774807f.svg)](https://buildkite.com/mokou/rustlings) @@ -214,6 +214,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Aleksei Trifonov

πŸ–‹
Darren Meehan

πŸ–‹
Jihchi Lee

πŸ–‹ +
Christofer Bertonha

πŸ–‹ From 00fbcd14f7f540b7a4f4591ec55dece83f5f35e0 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Tue, 22 Sep 2020 08:48:39 +0000 Subject: [PATCH 039/282] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index a0a56af4..edaa9f92 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -499,6 +499,15 @@ "contributions": [ "content" ] + }, + { + "login": "bertonha", + "name": "Christofer Bertonha", + "avatar_url": "https://avatars3.githubusercontent.com/u/1225902?v=4", + "profile": "https://github.com/bertonha", + "contributions": [ + "content" + ] } ], "contributorsPerLine": 8, From b6040e60619d07e149dc8205f854aee0ba7141e4 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Tue, 22 Sep 2020 08:49:56 +0000 Subject: [PATCH 040/282] docs: update README.md [skip ci] --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 96ad84e5..1612a234 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ![crab pet](https://i.imgur.com/LbZJgmm.gif) -[![All Contributors](https://img.shields.io/badge/all_contributors-54-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-55-orange.svg?style=flat-square)](#contributors-) # rustlings πŸ¦€β€οΈ [![Build status](https://badge.buildkite.com/7af93d81dc522c67a1ec8e33ff5705861b1cb36360b774807f.svg)](https://buildkite.com/mokou/rustlings) @@ -215,6 +215,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Darren Meehan

πŸ–‹
Jihchi Lee

πŸ–‹
Christofer Bertonha

πŸ–‹ +
Vivek Bharath Akupatni

πŸ’» ⚠️ From 83e7365fd8af52a9e97eaea6c8da8f0fd3e9f888 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Tue, 22 Sep 2020 08:49:57 +0000 Subject: [PATCH 041/282] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index edaa9f92..cb8f1bcd 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -508,6 +508,16 @@ "contributions": [ "content" ] + }, + { + "login": "apatniv", + "name": "Vivek Bharath Akupatni", + "avatar_url": "https://avatars2.githubusercontent.com/u/22565917?v=4", + "profile": "https://github.com/apatniv", + "contributions": [ + "code", + "test" + ] } ], "contributorsPerLine": 8, From 448d116a896f2f88ae7d5405fb83185499c29c4a Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Tue, 22 Sep 2020 08:50:50 +0000 Subject: [PATCH 042/282] docs: update README.md [skip ci] --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1612a234..5a6d822c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ![crab pet](https://i.imgur.com/LbZJgmm.gif) -[![All Contributors](https://img.shields.io/badge/all_contributors-55-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-56-orange.svg?style=flat-square)](#contributors-) # rustlings πŸ¦€β€οΈ [![Build status](https://badge.buildkite.com/7af93d81dc522c67a1ec8e33ff5705861b1cb36360b774807f.svg)](https://buildkite.com/mokou/rustlings) @@ -216,6 +216,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Jihchi Lee

πŸ–‹
Christofer Bertonha

πŸ–‹
Vivek Bharath Akupatni

πŸ’» ⚠️ +
DΓ­dac SementΓ© FernΓ‘ndez

πŸ’» πŸ–‹ From 144dec3fd3700283814b5a81bf8919fc50bc7da7 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Tue, 22 Sep 2020 08:50:51 +0000 Subject: [PATCH 043/282] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index cb8f1bcd..4624f751 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -518,6 +518,16 @@ "code", "test" ] + }, + { + "login": "DiD92", + "name": "DΓ­dac SementΓ© FernΓ‘ndez", + "avatar_url": "https://avatars3.githubusercontent.com/u/6002416?v=4", + "profile": "https://github.com/DiD92", + "contributions": [ + "code", + "content" + ] } ], "contributorsPerLine": 8, From 4a5e48e88fd416e78de0254d5283783c38ce9c9b Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Tue, 22 Sep 2020 08:52:28 +0000 Subject: [PATCH 044/282] docs: update README.md [skip ci] --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5a6d822c..3c2e1bc1 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ![crab pet](https://i.imgur.com/LbZJgmm.gif) -[![All Contributors](https://img.shields.io/badge/all_contributors-56-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-57-orange.svg?style=flat-square)](#contributors-) # rustlings πŸ¦€β€οΈ [![Build status](https://badge.buildkite.com/7af93d81dc522c67a1ec8e33ff5705861b1cb36360b774807f.svg)](https://buildkite.com/mokou/rustlings) @@ -218,6 +218,9 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Vivek Bharath Akupatni

πŸ’» ⚠️
DΓ­dac SementΓ© FernΓ‘ndez

πŸ’» πŸ–‹ + +
Rob Story

πŸ’» + From e66d2085b7bd087484b4baee0ad05fc8bbd419cc Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Tue, 22 Sep 2020 08:52:29 +0000 Subject: [PATCH 045/282] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 4624f751..ff82b615 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -528,6 +528,15 @@ "code", "content" ] + }, + { + "login": "wrobstory", + "name": "Rob Story", + "avatar_url": "https://avatars3.githubusercontent.com/u/2601457?v=4", + "profile": "https://github.com/wrobstory", + "contributions": [ + "code" + ] } ], "contributorsPerLine": 8, From 909b297ae303cd29cea91e5d9d51b95e8f6ebd27 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Tue, 22 Sep 2020 08:54:53 +0000 Subject: [PATCH 046/282] docs: update README.md [skip ci] --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3c2e1bc1..72e2f934 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ![crab pet](https://i.imgur.com/LbZJgmm.gif) -[![All Contributors](https://img.shields.io/badge/all_contributors-57-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-58-orange.svg?style=flat-square)](#contributors-) # rustlings πŸ¦€β€οΈ [![Build status](https://badge.buildkite.com/7af93d81dc522c67a1ec8e33ff5705861b1cb36360b774807f.svg)](https://buildkite.com/mokou/rustlings) @@ -220,6 +220,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Rob Story

πŸ’» +
Siobhan Jacobson

πŸ’» From 5996bd57ea82d93e1976a2df9e7c35a4cf6e86f8 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Tue, 22 Sep 2020 08:54:54 +0000 Subject: [PATCH 047/282] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index ff82b615..4f0b6413 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -537,6 +537,15 @@ "contributions": [ "code" ] + }, + { + "login": "siobhanjacobson", + "name": "Siobhan Jacobson", + "avatar_url": "https://avatars2.githubusercontent.com/u/28983835?v=4", + "profile": "https://github.com/siobhanjacobson", + "contributions": [ + "code" + ] } ], "contributorsPerLine": 8, From 08e9c7aa2ff34b3d1b0ba8fefdf2e5521efc32cc Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Tue, 22 Sep 2020 08:56:17 +0000 Subject: [PATCH 048/282] docs: update README.md [skip ci] --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 72e2f934..0b98b94c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ![crab pet](https://i.imgur.com/LbZJgmm.gif) -[![All Contributors](https://img.shields.io/badge/all_contributors-58-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-59-orange.svg?style=flat-square)](#contributors-) # rustlings πŸ¦€β€οΈ [![Build status](https://badge.buildkite.com/7af93d81dc522c67a1ec8e33ff5705861b1cb36360b774807f.svg)](https://buildkite.com/mokou/rustlings) @@ -221,6 +221,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Rob Story

πŸ’»
Siobhan Jacobson

πŸ’» +
Evan Carroll

πŸ–‹ From 599a44f90f51f2cb66e0ea8cec5814440d97ef31 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Tue, 22 Sep 2020 08:56:18 +0000 Subject: [PATCH 049/282] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 4f0b6413..071e42dc 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -546,6 +546,15 @@ "contributions": [ "code" ] + }, + { + "login": "EvanCarroll", + "name": "Evan Carroll", + "avatar_url": "https://avatars2.githubusercontent.com/u/19922?v=4", + "profile": "https://www.linkedin.com/in/evancarroll/", + "contributions": [ + "content" + ] } ], "contributorsPerLine": 8, From dc94fcc6e8299bd6a090fcbaf2ea0d661d36a0fa Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Tue, 22 Sep 2020 08:57:32 +0000 Subject: [PATCH 050/282] docs: update README.md [skip ci] --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0b98b94c..c09c993f 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ![crab pet](https://i.imgur.com/LbZJgmm.gif) -[![All Contributors](https://img.shields.io/badge/all_contributors-59-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-60-orange.svg?style=flat-square)](#contributors-) # rustlings πŸ¦€β€οΈ [![Build status](https://badge.buildkite.com/7af93d81dc522c67a1ec8e33ff5705861b1cb36360b774807f.svg)](https://buildkite.com/mokou/rustlings) @@ -222,6 +222,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Rob Story

πŸ’»
Siobhan Jacobson

πŸ’»
Evan Carroll

πŸ–‹ +
Jawaad Mahmood

πŸ–‹ From 19a0c1f3cb45dd03e100580167489d9bf8a4889b Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Tue, 22 Sep 2020 08:57:33 +0000 Subject: [PATCH 051/282] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 071e42dc..df3a9da7 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -555,6 +555,15 @@ "contributions": [ "content" ] + }, + { + "login": "jmahmood", + "name": "Jawaad Mahmood", + "avatar_url": "https://avatars3.githubusercontent.com/u/95606?v=4", + "profile": "http://www.jawaadmahmood.com", + "contributions": [ + "content" + ] } ], "contributorsPerLine": 8, From 8f28bcf7040d484e929da0446f91e95be9d44f7d Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Tue, 22 Sep 2020 09:04:32 +0000 Subject: [PATCH 052/282] docs: update README.md [skip ci] --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c09c993f..df6bfea3 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ![crab pet](https://i.imgur.com/LbZJgmm.gif) -[![All Contributors](https://img.shields.io/badge/all_contributors-60-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-61-orange.svg?style=flat-square)](#contributors-) # rustlings πŸ¦€β€οΈ [![Build status](https://badge.buildkite.com/7af93d81dc522c67a1ec8e33ff5705861b1cb36360b774807f.svg)](https://buildkite.com/mokou/rustlings) @@ -223,6 +223,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Siobhan Jacobson

πŸ’»
Evan Carroll

πŸ–‹
Jawaad Mahmood

πŸ–‹ +
Gaurang Tandon

πŸ–‹ From c7eabe61bb3cc83fd483d04a318f1b5ea41387bd Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Tue, 22 Sep 2020 09:04:33 +0000 Subject: [PATCH 053/282] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index df3a9da7..bbf53864 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -564,6 +564,15 @@ "contributions": [ "content" ] + }, + { + "login": "GaurangTandon", + "name": "Gaurang Tandon", + "avatar_url": "https://avatars1.githubusercontent.com/u/6308683?v=4", + "profile": "https://github.com/GaurangTandon", + "contributions": [ + "content" + ] } ], "contributorsPerLine": 8, From 79c3ada49b95aba73644a5148ad3518a4adb9fe7 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Tue, 22 Sep 2020 09:31:41 +0000 Subject: [PATCH 054/282] docs: update README.md [skip ci] --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index df6bfea3..6cb0535c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ![crab pet](https://i.imgur.com/LbZJgmm.gif) -[![All Contributors](https://img.shields.io/badge/all_contributors-61-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-62-orange.svg?style=flat-square)](#contributors-) # rustlings πŸ¦€β€οΈ [![Build status](https://badge.buildkite.com/7af93d81dc522c67a1ec8e33ff5705861b1cb36360b774807f.svg)](https://buildkite.com/mokou/rustlings) @@ -224,6 +224,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Evan Carroll

πŸ–‹
Jawaad Mahmood

πŸ–‹
Gaurang Tandon

πŸ–‹ +
Stefan Kupresak

πŸ–‹ From 01f4bb86c3f8e3633ae65172d46fd822967aef54 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Tue, 22 Sep 2020 09:31:42 +0000 Subject: [PATCH 055/282] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index bbf53864..65302ad7 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -573,6 +573,15 @@ "contributions": [ "content" ] + }, + { + "login": "dev-cyprium", + "name": "Stefan Kupresak", + "avatar_url": "https://avatars1.githubusercontent.com/u/6002628?v=4", + "profile": "https://github.com/dev-cyprium", + "contributions": [ + "content" + ] } ], "contributorsPerLine": 8, From 2933f51949283c80190aca0a0ae06ee723263cc1 Mon Sep 17 00:00:00 2001 From: Greg Leonard <45019882+greg-el@users.noreply.github.com> Date: Fri, 25 Sep 2020 12:39:52 +0100 Subject: [PATCH 056/282] chore: Change point to comma in from_into.rs A typo in the fn test_bad_age() hint message had a point rather than comma Prev: // Test that "Mark.twenty" Current: // Test that "Mark,twenty" --- exercises/conversions/from_into.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/conversions/from_into.rs b/exercises/conversions/from_into.rs index 4f4da538..f24cf61b 100644 --- a/exercises/conversions/from_into.rs +++ b/exercises/conversions/from_into.rs @@ -75,7 +75,7 @@ mod tests { } #[test] fn test_bad_age() { - // Test that "Mark.twenty" will return the default person due to an error in parsing age + // Test that "Mark,twenty" will return the default person due to an error in parsing age let p = Person::from("Mark,twenty"); assert_eq!(p.name, "John"); assert_eq!(p.age, 30); From 9f38b54a2dfe5901605ee57541666033c6682e2b Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Fri, 25 Sep 2020 13:43:01 +0200 Subject: [PATCH 057/282] docs: add greg-el as a contributor * docs: update README.md [skip ci] * docs: update .all-contributorsrc [skip ci] Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com> --- .all-contributorsrc | 9 +++++++++ README.md | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index 65302ad7..98a7e9f0 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -582,6 +582,15 @@ "contributions": [ "content" ] + }, + { + "login": "greg-el", + "name": "Greg Leonard", + "avatar_url": "https://avatars3.githubusercontent.com/u/45019882?v=4", + "profile": "https://github.com/greg-el", + "contributions": [ + "content" + ] } ], "contributorsPerLine": 8, diff --git a/README.md b/README.md index 6cb0535c..cfe7598c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ![crab pet](https://i.imgur.com/LbZJgmm.gif) -[![All Contributors](https://img.shields.io/badge/all_contributors-62-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-63-orange.svg?style=flat-square)](#contributors-) # rustlings πŸ¦€β€οΈ [![Build status](https://badge.buildkite.com/7af93d81dc522c67a1ec8e33ff5705861b1cb36360b774807f.svg)](https://buildkite.com/mokou/rustlings) @@ -225,6 +225,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Jawaad Mahmood

πŸ–‹
Gaurang Tandon

πŸ–‹
Stefan Kupresak

πŸ–‹ +
Greg Leonard

πŸ–‹ From c03e1e6c6c7c619e241f23b328db2f2dcffa3d0f Mon Sep 17 00:00:00 2001 From: Alexx Roche Date: Sun, 27 Sep 2020 21:57:51 +0200 Subject: [PATCH 058/282] chore: fixed test name --- src/exercise.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/exercise.rs b/src/exercise.rs index e70538bb..b07d7a11 100644 --- a/src/exercise.rs +++ b/src/exercise.rs @@ -315,7 +315,7 @@ mod test { #[test] fn test_exercise_with_output() { let exercise = Exercise { - name: "finished_exercise".into(), + name: "exercise_with_output".into(), path: PathBuf::from("tests/fixture/success/testSuccess.rs"), mode: Mode::Test, hint: String::new(), From 2ec0bdfd99928e05dc8aa1d2464f498ee22dadf9 Mon Sep 17 00:00:00 2001 From: Yashodhan Joshi Date: Thu, 1 Oct 2020 08:31:42 +0530 Subject: [PATCH 059/282] fix(variables5) : make shadowing more prominent closes #375 --- exercises/variables/variables5.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/exercises/variables/variables5.rs b/exercises/variables/variables5.rs index 5b2c2fa3..da37ae99 100644 --- a/exercises/variables/variables5.rs +++ b/exercises/variables/variables5.rs @@ -4,8 +4,8 @@ // I AM NOT DONE fn main() { - let number = "3"; // don't change this line - println!("Number {}", number); + let number = "T-H-R-E-E"; + println!("Spell a Number : {}", number); number = 3; - println!("Number {}", number); + println!("Number plus two is : {}", number + 2); } From 5382cd696acd8bde16a9029510fc838ec0594e29 Mon Sep 17 00:00:00 2001 From: jieniu$ Date: Thu, 1 Oct 2020 20:12:24 -0600 Subject: [PATCH 060/282] docs: Fix grammatical errors in Readme --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index cfe7598c..b091cf8d 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Greetings and welcome to `rustlings`. This project contains small exercises to g _...looking for the old, web-based version of Rustlings? Try [here](https://github.com/rust-lang/rustlings/tree/rustlings-1)_ -Alternatively, for a first-time Rust learner, there's several other resources: +Alternatively, for a first-time Rust learner, there are several other resources: - [The Book](https://doc.rust-lang.org/book/index.html) - The most comprehensive resource for learning Rust, but a bit theoretical sometimes. You will be using this along with Rustlings! - [Rust By Example](https://doc.rust-lang.org/rust-by-example/index.html) - Learn Rust by solving little exercises! It's almost like `rustlings`, but online @@ -76,7 +76,7 @@ Then, same as above, run `rustlings` to get started. The exercises are sorted by topic and can be found in the subdirectory `rustlings/exercises/`. For every topic there is an additional README file with some resources to get you started on the topic. We really recommend that you have a look at them before you start. -The task is simple. Most exercises contain an error that keep them from compiling, and it's up to you to fix it! Some exercises are also run as tests, but rustlings handles them all the same. To run the exercises in the recommended order, execute: +The task is simple. Most exercises contain an error that keeps them from compiling, and it's up to you to fix it! Some exercises are also run as tests, but rustlings handles them all the same. To run the exercises in the recommended order, execute: ```bash rustlings watch From 89c07b5e437d6a33728bb12b4a0cef44a1c1d3c9 Mon Sep 17 00:00:00 2001 From: mokou Date: Mon, 5 Oct 2020 18:42:26 +0200 Subject: [PATCH 061/282] release: 4.1.0 --- CHANGELOG.md | 23 +++++++++++++++++++++++ Cargo.lock | 2 +- Cargo.toml | 2 +- README.md | 2 +- 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a96df52c..1d156aa6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,26 @@ + +## 4.1.0 (2020-10-05) + +#### Bug Fixes + +* Update rustlings version in Cargo.lock ([1cc40bc9](https://github.com/rust-lang/rustlings/commit/1cc40bc9ce95c23d56f6d91fa1c4deb646231fef)) +* **arc1:** index mod should equal thread count ([b4062ef6](https://github.com/rust-lang/rustlings/commit/b4062ef6993e80dac107c4093ea85166ad3ee0fa)) +* **enums3:** Update Message::ChangeColor to take a tuple. (#457) ([4b6540c7](https://github.com/rust-lang/rustlings/commit/4b6540c71adabad647de8a09e57295e7c7c7d794)) +* **exercises:** adding question mark to quiz2 ([101072ab](https://github.com/rust-lang/rustlings/commit/101072ab9f8c80b40b8b88cb06cbe38aca2481c5)) +* **generics3:** clarify grade change ([47f7672c](https://github.com/rust-lang/rustlings/commit/47f7672c0307732056e7426e81d351f0dd7e22e5)) +* **structs3:** Small adjustment of variable name ([114b54cb](https://github.com/rust-lang/rustlings/commit/114b54cbdb977234b39e5f180d937c14c78bb8b2)) +* **using_as:** Add test so that proper type is returned. (#512) ([3286c5ec](https://github.com/rust-lang/rustlings/commit/3286c5ec19ea5fb7ded81d047da5f8594108a490)) + +#### Features + +* Added iterators1.rs exercise ([9642f5a3](https://github.com/rust-lang/rustlings/commit/9642f5a3f686270a4f8f6ba969919ddbbc4f7fdd)) +* Add ability to run rustlings on repl.it (#471) ([8f7b5bd0](https://github.com/rust-lang/rustlings/commit/8f7b5bd00eb83542b959830ef55192d2d76db90a)) +* Add gitpod support (#473) ([4821a8be](https://github.com/rust-lang/rustlings/commit/4821a8be94af4f669042a06ab917934cfacd032f)) +* Remind the user of the hint option (#425) ([816b1f5e](https://github.com/rust-lang/rustlings/commit/816b1f5e85d6cc6e72673813a85d0ada2a8f84af)) +* Remind the user of the hint option (#425) ([9f61db5d](https://github.com/rust-lang/rustlings/commit/9f61db5dbe38538cf06571fcdd5f806e7901e83a)) +* **cli:** Added 'cls' command to 'watch' mode (#474) ([4f2468e1](https://github.com/rust-lang/rustlings/commit/4f2468e14f574a93a2e9b688367b5752ed96ae7b)) +* **try_from_into:** Add insufficient length test (#469) ([523d18b8](https://github.com/rust-lang/rustlings/commit/523d18b873a319f7c09262f44bd40e2fab1830e5)) + ## 4.0.0 (2020-07-08) diff --git a/Cargo.lock b/Cargo.lock index 732a4b59..cdc1af35 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -592,7 +592,7 @@ dependencies = [ [[package]] name = "rustlings" -version = "4.0.0" +version = "4.1.0" dependencies = [ "assert_cmd 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)", "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index d4180da2..68142845 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rustlings" -version = "4.0.0" +version = "4.1.0" authors = ["Marisa ", "Carol (Nichols || Goulding) "] edition = "2018" diff --git a/README.md b/README.md index b091cf8d..efad42b8 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ Basically: Clone the repository, checkout to the latest tag, run `cargo install` ```bash git clone https://github.com/rust-lang/rustlings cd rustlings -git checkout tags/4.0.0 # or whatever the latest version is (find out at https://github.com/rust-lang/rustlings/releases/latest) +git checkout tags/4.1.0 # or whatever the latest version is (find out at https://github.com/rust-lang/rustlings/releases/latest) cargo install --force --path . ``` From e1fdfbb062e655b8cb4ddb770abe3f13cc606ec3 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Fri, 9 Oct 2020 00:15:53 +0000 Subject: [PATCH 062/282] docs: update README.md [skip ci] --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index efad42b8..3433e8e2 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ![crab pet](https://i.imgur.com/LbZJgmm.gif) -[![All Contributors](https://img.shields.io/badge/all_contributors-63-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-64-orange.svg?style=flat-square)](#contributors-) # rustlings πŸ¦€β€οΈ [![Build status](https://badge.buildkite.com/7af93d81dc522c67a1ec8e33ff5705861b1cb36360b774807f.svg)](https://buildkite.com/mokou/rustlings) @@ -226,6 +226,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Gaurang Tandon

πŸ–‹
Stefan Kupresak

πŸ–‹
Greg Leonard

πŸ–‹ +
Ryan McQuen

πŸ’» From 29dd0b1e410715fee8b18eee54da67405d2c0625 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Fri, 9 Oct 2020 00:15:54 +0000 Subject: [PATCH 063/282] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 98a7e9f0..92c3af81 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -591,6 +591,15 @@ "contributions": [ "content" ] + }, + { + "login": "ryanpcmcquen", + "name": "Ryan McQuen", + "avatar_url": "https://avatars3.githubusercontent.com/u/772937?v=4", + "profile": "https://ryanpcmcquen.org", + "contributions": [ + "code" + ] } ], "contributorsPerLine": 8, From 18e0bfef1de53071e353ba1ec5837002ff7290e6 Mon Sep 17 00:00:00 2001 From: Ryan McQuen Date: Sat, 10 Oct 2020 04:11:57 -0700 Subject: [PATCH 064/282] fix(quiz3): Second test is for odd numbers, not even. (#553) --- exercises/tests/tests3.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/tests/tests3.rs b/exercises/tests/tests3.rs index 06cf7ea7..3424f940 100644 --- a/exercises/tests/tests3.rs +++ b/exercises/tests/tests3.rs @@ -20,7 +20,7 @@ mod tests { } #[test] - fn is_false_when_even() { + fn is_false_when_odd() { assert!(); } } From 2b1fb2b739bf9ad8d6b7b12af25fee173011bfc4 Mon Sep 17 00:00:00 2001 From: Axel Viala Date: Sat, 10 Oct 2020 16:04:19 +0200 Subject: [PATCH 065/282] feat(primitive_types6): Add a test (#548) Co-authored-by: Annika <56906084+AnnikaCodes@users.noreply.github.com> Co-authored-by: fmoko --- exercises/primitive_types/primitive_types6.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/exercises/primitive_types/primitive_types6.rs b/exercises/primitive_types/primitive_types6.rs index 2bc817e9..5c6c5a43 100644 --- a/exercises/primitive_types/primitive_types6.rs +++ b/exercises/primitive_types/primitive_types6.rs @@ -1,11 +1,16 @@ // primitive_types6.rs // Use a tuple index to access the second element of `numbers`. -// You can put this right into the `println!` where the ??? is. +// You can put the expression for the second element where ??? is so that the test passes. // Execute `rustlings hint primitive_types6` for hints! // I AM NOT DONE -fn main() { +#[test] +fn indexing_tuple() { let numbers = (1, 2, 3); - println!("The second number is {}", ???); + /// Replace below ??? with the tuple indexing syntax. + let second = ???; + + assert_eq!(2, second + "This is not the 2nd number in the tuple!") } From ded1474bbb05870beac061f1bdac26ef98035d0d Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Sat, 10 Oct 2020 16:07:15 +0200 Subject: [PATCH 066/282] docs: add darnuria as a contributor (#554) Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com> --- .all-contributorsrc | 9 +++++++++ README.md | 5 ++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index 92c3af81..8bec2408 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -600,6 +600,15 @@ "contributions": [ "code" ] + }, + { + "login": "darnuria", + "name": "Axel Viala", + "avatar_url": "https://avatars1.githubusercontent.com/u/2827553?v=4", + "profile": "https://darnuria.eu", + "contributions": [ + "code" + ] } ], "contributorsPerLine": 8, diff --git a/README.md b/README.md index 3433e8e2..1e4e9532 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ![crab pet](https://i.imgur.com/LbZJgmm.gif) -[![All Contributors](https://img.shields.io/badge/all_contributors-64-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-65-orange.svg?style=flat-square)](#contributors-) # rustlings πŸ¦€β€οΈ [![Build status](https://badge.buildkite.com/7af93d81dc522c67a1ec8e33ff5705861b1cb36360b774807f.svg)](https://buildkite.com/mokou/rustlings) @@ -228,6 +228,9 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Greg Leonard

πŸ–‹
Ryan McQuen

πŸ’» + +
Axel Viala

πŸ’» + From cc5b9b772a219cc114a31e762bdf0eaa63cb3221 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Sat, 10 Oct 2020 17:08:22 +0200 Subject: [PATCH 067/282] docs: add AnnikaCodes as a contributor (#557) Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com> Co-authored-by: fmoko --- .all-contributorsrc | 9 +++++++++ README.md | 1 + 2 files changed, 10 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 8bec2408..56e4d53f 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -601,6 +601,15 @@ "code" ] }, + { + "login": "AnnikaCodes", + "name": "Annika", + "avatar_url": "https://avatars3.githubusercontent.com/u/56906084?v=4", + "profile": "https://github.com/AnnikaCodes", + "contributions": [ + "review" + ] + }, { "login": "darnuria", "name": "Axel Viala", diff --git a/README.md b/README.md index 1e4e9532..a618abb5 100644 --- a/README.md +++ b/README.md @@ -229,6 +229,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Ryan McQuen

πŸ’» +
Annika

πŸ‘€
Axel Viala

πŸ’» From e6bde22f9c65e1da07602021d759ab702f7317d4 Mon Sep 17 00:00:00 2001 From: Rastamo <42067541+Rastamo@users.noreply.github.com> Date: Sun, 11 Oct 2020 14:00:03 +0200 Subject: [PATCH 068/282] chore: primitive_types6 mode changed to test (#559) primitive_types6 exercise was changed to test yesterday, but info.toml file wasn't updated. I think this change should fix it. --- info.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/info.toml b/info.toml index 28bf24d6..2d0abdb1 100644 --- a/info.toml +++ b/info.toml @@ -210,7 +210,7 @@ of the tuple. You can do it!!""" [[exercises]] name = "primitive_types6" path = "exercises/primitive_types/primitive_types6.rs" -mode = "compile" +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 From 4fb230daf1251444fcf29e085cee222a91f8a37e Mon Sep 17 00:00:00 2001 From: Matthew Smillie Date: Tue, 13 Oct 2020 23:18:41 -0700 Subject: [PATCH 069/282] fix(primitive_types6): missing comma in test --- exercises/primitive_types/primitive_types6.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/primitive_types/primitive_types6.rs b/exercises/primitive_types/primitive_types6.rs index 5c6c5a43..0fa42b27 100644 --- a/exercises/primitive_types/primitive_types6.rs +++ b/exercises/primitive_types/primitive_types6.rs @@ -11,6 +11,6 @@ fn indexing_tuple() { /// Replace below ??? with the tuple indexing syntax. let second = ???; - assert_eq!(2, second + assert_eq!(2, second, "This is not the 2nd number in the tuple!") } From 472d8592d65c8275332a20dfc269e7ac0d41bc88 Mon Sep 17 00:00:00 2001 From: Matthew Smillie Date: Tue, 13 Oct 2020 23:20:17 -0700 Subject: [PATCH 070/282] fix(primitive_types6): remove 'unused doc comment' warning --- exercises/primitive_types/primitive_types6.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/primitive_types/primitive_types6.rs b/exercises/primitive_types/primitive_types6.rs index 0fa42b27..b8c9b82b 100644 --- a/exercises/primitive_types/primitive_types6.rs +++ b/exercises/primitive_types/primitive_types6.rs @@ -8,7 +8,7 @@ #[test] fn indexing_tuple() { let numbers = (1, 2, 3); - /// Replace below ??? with the tuple indexing syntax. + // Replace below ??? with the tuple indexing syntax. let second = ???; assert_eq!(2, second, From 5643ef05bc81e4a840e9456f4406a769abbe1392 Mon Sep 17 00:00:00 2001 From: Roberto Vidal Date: Fri, 30 Oct 2020 14:39:28 +0100 Subject: [PATCH 071/282] fix: more unique temp_file --- src/exercise.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/exercise.rs b/src/exercise.rs index b07d7a11..283b2b90 100644 --- a/src/exercise.rs +++ b/src/exercise.rs @@ -11,10 +11,15 @@ 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"; -// Get a temporary file name that is hopefully unique to this process +// Get a temporary file name that is hopefully unique #[inline] fn temp_file() -> String { - format!("./temp_{}", process::id()) + let thread_id: String = format!("{:?}", std::thread::current().id()) + .chars() + .filter(|c| c.is_alphanumeric()) + .collect(); + + format!("./temp_{}_{}", process::id(), thread_id) } // The mode of the exercise. From 0c12fa31c57c03c6287458a0a8aca7afd057baf6 Mon Sep 17 00:00:00 2001 From: sazid Date: Mon, 26 Oct 2020 12:54:32 +0600 Subject: [PATCH 072/282] feat: Add Vec exercises --- exercises/collections/README.md | 20 +++++++++++++++++ exercises/collections/vec1.rs | 25 ++++++++++++++++++++++ exercises/collections/vec2.rs | 38 +++++++++++++++++++++++++++++++++ info.toml | 30 ++++++++++++++++++++++++++ 4 files changed, 113 insertions(+) create mode 100644 exercises/collections/README.md create mode 100644 exercises/collections/vec1.rs create mode 100644 exercises/collections/vec2.rs diff --git a/exercises/collections/README.md b/exercises/collections/README.md new file mode 100644 index 00000000..9ded29a0 --- /dev/null +++ b/exercises/collections/README.md @@ -0,0 +1,20 @@ +### Collections + +Rust’s standard library includes a number of very useful data +structures called collections. Most other data types represent one +specific value, but collections can contain multiple values. Unlike +the built-in array and tuple types, the data these collections point +to is stored on the heap, which means the amount of data does not need +to be known at compile time and can grow or shrink as the program +runs. + +This exercise will get you familiar with two fundamental data +structures that are used very often in Rust programs: + +* A *vector* allows you to store a variable number of values next to + each other. +* A *hash map* allows you to associate a value with a particular key. + You may also know this by the names *map* in C++, *dictionary* in + Python or an *associative array* in other languages. + +[Rust book chapter](https://doc.rust-lang.org/stable/book/ch08-01-vectors.html) diff --git a/exercises/collections/vec1.rs b/exercises/collections/vec1.rs new file mode 100644 index 00000000..ac3d9f1a --- /dev/null +++ b/exercises/collections/vec1.rs @@ -0,0 +1,25 @@ +// vec1.rs +// Your task is to create a `Vec` which holds the exact same elements +// as in the array `a`. +// Make me compile and pass the test! +// Execute the command `rustlings hint collections1` if you need hints. + +// I AM NOT DONE + +fn array_and_vec() -> ([i32; 4], Vec) { + let a = [10, 20, 30, 40]; // a plain array + let v = // TODO: declare your vector here with the macro for vectors + + (a, v) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_array_and_vec_similarity() { + let (a, v) = array_and_vec(); + assert!(a.iter().zip(v.iter()).all(|(x, y)| x == y)); + } +} diff --git a/exercises/collections/vec2.rs b/exercises/collections/vec2.rs new file mode 100644 index 00000000..ec6cfc00 --- /dev/null +++ b/exercises/collections/vec2.rs @@ -0,0 +1,38 @@ +// vec2.rs +// A Vec of even numbers is given. Your task is to complete the loop +// so that each number in the Vec is multiplied by 2. +// +// Make me pass the test! +// +// Execute the command `rustlings hint collections2` if you need +// hints. + +// I AM NOT DONE + +fn vec_loop(mut v: Vec) -> Vec { + for i in v.iter_mut() { + // TODO: Fill this up so that each element in the Vec `v` is + // multiplied by 2. + } + + // At this point, `v` should be equal to [4, 8, 12, 16, 20]. + v +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_vec_loop() { + let v: Vec = (1..).filter(|x| x % 2 == 0).take(5).collect(); + let ans = vec_loop(v.clone()); + + assert_eq!( + ans, + v.iter() + .map(|x| x * 2) + .collect::>() + ); + } +} diff --git a/info.toml b/info.toml index 2d0abdb1..56605a7b 100644 --- a/info.toml +++ b/info.toml @@ -370,6 +370,36 @@ its internal structure (the `fruits` and `veggies` modules and associated constants). It's almost there except for one keyword missing for each constant.""" +# COLLECTIONS + +[[exercises]] +name = "collections1" +path = "exercises/collections/vec1.rs" +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. + +2. The second way, which is simpler is to use the `vec![]` macro and + 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. +""" + +[[exercises]] +name = "collections2" +path = "exercises/collections/vec2.rs" +mode = "test" +hint = """ +Hint 1: `i` is each element from the Vec as they are being iterated. + Can you try multiplying this? + +Hint 2: Check the suggestion from the compiler error ;) +""" + # MACROS [[exercises]] From 633c00cf8071e1e82959a3010452a32f34f29fc9 Mon Sep 17 00:00:00 2001 From: sazid Date: Mon, 26 Oct 2020 18:08:48 +0600 Subject: [PATCH 073/282] feat: Add HashMap exercises --- exercises/collections/hashmap1.rs | 46 +++++++++++++++++ exercises/collections/hashmap2.rs | 83 +++++++++++++++++++++++++++++++ info.toml | 22 ++++++++ 3 files changed, 151 insertions(+) create mode 100644 exercises/collections/hashmap1.rs create mode 100644 exercises/collections/hashmap2.rs diff --git a/exercises/collections/hashmap1.rs b/exercises/collections/hashmap1.rs new file mode 100644 index 00000000..b1dc0bbd --- /dev/null +++ b/exercises/collections/hashmap1.rs @@ -0,0 +1,46 @@ +// hashmap1.rs +// A basket of fruits in the form of a hash map needs to be defined. +// The key represents the name of the fruit and the value represents +// how many of that particular fruit is in the basket. You have to put +// at least three different types of fruits (e.g apple, banana, mango) +// in the basket and the total count of all the fruits should be at +// least five. +// +// Make me compile and pass the tests! +// +// Execute the command `rustlings hint collections3` if you need +// hints. + +// I AM NOT DONE + +use std::collections::HashMap; + +fn fruit_basket() -> HashMap { + let mut basket = // TODO: declare your hash map here. + + // Two bananas are already given for you :) + basket.insert(String::from("banana"), 2); + + // TODO: Put more fruits in your basket here. + + basket +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn at_least_three_types_of_fruits() { + let basket = fruit_basket(); + assert!(basket.len() >= 3); + } + + #[test] + fn at_least_five_fruits() { + let basket = fruit_basket(); + assert!(basket + .values() + .sum::() >= 5); + } +} diff --git a/exercises/collections/hashmap2.rs b/exercises/collections/hashmap2.rs new file mode 100644 index 00000000..7e25be7c --- /dev/null +++ b/exercises/collections/hashmap2.rs @@ -0,0 +1,83 @@ +// hashmap2.rs + +// A basket of fruits in the form of a hash map is given. The key +// represents the name of the fruit and the value represents how many +// of that particular fruit is in the basket. You have to put *MORE +// THAN 11* fruits in the basket. Three types of fruits - Apple (4), +// Mango (2) and Lichi (5) are already given in the basket. You are +// not allowed to insert any more of these fruits! +// +// Make me pass the tests! +// +// Execute the command `rustlings hint collections4` if you need +// hints. + +// I AM NOT DONE + +use std::collections::HashMap; + +#[derive(Hash, PartialEq, Eq)] +enum Fruit { + Apple, + Banana, + Mango, + Lichi, + Pineapple, +} + +fn fruit_basket(basket: &mut HashMap) { + let fruit_kinds = vec![ + Fruit::Apple, + Fruit::Banana, + Fruit::Mango, + Fruit::Lichi, + Fruit::Pineapple, + ]; + + for fruit in fruit_kinds { + // TODO: Put new fruits if not already present. Note that you + // are not allowed to put any type of fruit that's already + // present! + } +} + +#[cfg(test)] +mod tests { + use super::*; + + fn get_fruit_basket() -> HashMap { + let mut basket = HashMap::::new(); + basket.insert(Fruit::Apple, 4); + basket.insert(Fruit::Mango, 2); + basket.insert(Fruit::Lichi, 5); + + basket + } + + #[test] + fn test_given_fruits_are_not_modified() { + let mut basket = get_fruit_basket(); + fruit_basket(&mut basket); + assert_eq!(*basket.get(&Fruit::Apple).unwrap(), 4); + assert_eq!(*basket.get(&Fruit::Mango).unwrap(), 2); + assert_eq!(*basket.get(&Fruit::Lichi).unwrap(), 5); + } + + #[test] + fn at_least_five_types_of_fruits() { + let mut basket = get_fruit_basket(); + fruit_basket(&mut basket); + let count_fruit_kinds = basket.len(); + assert!(count_fruit_kinds == 5); + } + + #[test] + fn greater_than_eleven_fruits() { + let mut basket = get_fruit_basket(); + fruit_basket(&mut basket); + let count = basket + .values() + .sum::(); + assert!(count > 11); + } +} diff --git a/info.toml b/info.toml index 56605a7b..c52702f7 100644 --- a/info.toml +++ b/info.toml @@ -400,6 +400,28 @@ Hint 1: `i` is each element from the Vec as they are being iterated. Hint 2: Check the suggestion from the compiler error ;) """ +[[exercises]] +name = "collections3" +path = "exercises/collections/hashmap1.rs" +mode = "test" +hint = """ +Hint 1: Take a look at the return type of the function to figure out + 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. +""" + +[[exercises]] +name = "collections4" +path = "exercises/collections/hashmap2.rs" +mode = "test" +hint = """ +Use the `entry()` and `or_insert()` methods of `HashMap` to achieve this. + +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 +""" + # MACROS [[exercises]] From 535a8c82432b68b83cca3e8a42a7c9e26a09c6cd Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Fri, 30 Oct 2020 19:29:36 +0000 Subject: [PATCH 074/282] docs: update README.md [skip ci] --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a618abb5..81962273 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ![crab pet](https://i.imgur.com/LbZJgmm.gif) -[![All Contributors](https://img.shields.io/badge/all_contributors-65-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-67-orange.svg?style=flat-square)](#contributors-) # rustlings πŸ¦€β€οΈ [![Build status](https://badge.buildkite.com/7af93d81dc522c67a1ec8e33ff5705861b1cb36360b774807f.svg)](https://buildkite.com/mokou/rustlings) @@ -231,6 +231,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Annika

πŸ‘€
Axel Viala

πŸ’» +
Mohammed Sazid Al Rashid

πŸ–‹ πŸ’» From 51631f4c2e4246ddfa6be07a00cf597f51bca647 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Fri, 30 Oct 2020 19:29:37 +0000 Subject: [PATCH 075/282] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 56e4d53f..f383a3ae 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -618,6 +618,16 @@ "contributions": [ "code" ] + }, + { + "login": "sazid", + "name": "Mohammed Sazid Al Rashid", + "avatar_url": "https://avatars1.githubusercontent.com/u/2370167?v=4", + "profile": "https://sazid.github.io", + "contributions": [ + "content", + "code" + ] } ], "contributorsPerLine": 8, From 21bfb2d4777429c87d8d3b5fbf0ce66006dcd034 Mon Sep 17 00:00:00 2001 From: Caleb Webber Date: Thu, 5 Nov 2020 03:59:25 -0500 Subject: [PATCH 076/282] fix(installation): Update the MinRustVersion closes #577df Co-authored-by: Caleb Webber --- install.ps1 | 2 +- install.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/install.ps1 b/install.ps1 index f7472ad1..32167f06 100644 --- a/install.ps1 +++ b/install.ps1 @@ -53,7 +53,7 @@ function vercomp($v1, $v2) { } $rustVersion = $(rustc --version).Split(" ")[1] -$minRustVersion = "1.31" +$minRustVersion = "1.39" 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 a19c280a..e986e741 100755 --- a/install.sh +++ b/install.sh @@ -87,7 +87,7 @@ function vercomp() { } RustVersion=$(rustc --version | cut -d " " -f 2) -MinRustVersion=1.31 +MinRustVersion=1.39 vercomp $RustVersion $MinRustVersion if [ $? -eq 2 ] then From 68e646f8aa04b4297fe205472334132cdf001bbc Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Thu, 5 Nov 2020 10:03:43 +0100 Subject: [PATCH 077/282] docs: add seeplusplus as a contributor --- .all-contributorsrc | 9 +++++++++ README.md | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index f383a3ae..84b2365e 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -628,6 +628,15 @@ "content", "code" ] + }, + { + "login": "seeplusplus", + "name": "Caleb Webber", + "avatar_url": "https://avatars1.githubusercontent.com/u/17479099?v=4", + "profile": "https://codingthemsoftly.com", + "contributions": [ + "maintenance" + ] } ], "contributorsPerLine": 8, diff --git a/README.md b/README.md index 81962273..75a403f5 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ![crab pet](https://i.imgur.com/LbZJgmm.gif) -[![All Contributors](https://img.shields.io/badge/all_contributors-67-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-68-orange.svg?style=flat-square)](#contributors-) # rustlings πŸ¦€β€οΈ [![Build status](https://badge.buildkite.com/7af93d81dc522c67a1ec8e33ff5705861b1cb36360b774807f.svg)](https://buildkite.com/mokou/rustlings) @@ -232,6 +232,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Annika

πŸ‘€
Axel Viala

πŸ’»
Mohammed Sazid Al Rashid

πŸ–‹ πŸ’» +
Caleb Webber

🚧 From d61b4e5a13b44d72d004082f523fa1b6b24c1aca Mon Sep 17 00:00:00 2001 From: Caleb Webber Date: Thu, 5 Nov 2020 19:29:16 -0500 Subject: [PATCH 078/282] fix: log error output when inotify limit is exceeded closes #472 --- src/main.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index b5814bfb..d0299e33 100644 --- a/src/main.rs +++ b/src/main.rs @@ -119,7 +119,12 @@ fn main() { verify(&exercises, verbose).unwrap_or_else(|_| std::process::exit(1)); } - if matches.subcommand_matches("watch").is_some() && watch(&exercises, verbose).is_ok() { + if matches.subcommand_matches("watch").is_some() { + if let Err(e) = watch(&exercises, verbose) { + println!("Error: Could not watch your progess. Error message was {:?}.", e); + println!("Most likely you've run out of disk space or your 'inotify limit' has been reached."); + std::process::exit(1); + } println!( "{emoji} All exercises completed! {emoji}", emoji = Emoji("πŸŽ‰", "β˜…") From 197d3a3d8961b2465579218a6749b2b2cefa8ddd Mon Sep 17 00:00:00 2001 From: JP Date: Sat, 7 Nov 2020 13:54:14 +0100 Subject: [PATCH 079/282] fix(iterators2): Update description (#578) grammar fix in the description --- exercises/standard_library_types/iterators2.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/standard_library_types/iterators2.rs b/exercises/standard_library_types/iterators2.rs index 837725f0..84d14ae6 100644 --- a/exercises/standard_library_types/iterators2.rs +++ b/exercises/standard_library_types/iterators2.rs @@ -1,5 +1,5 @@ // iterators2.rs -// In this module, you'll learn some of unique advantages that iterators can offer. +// In this module, you'll learn some of the unique advantages that iterators can offer. // Step 1. Complete the `capitalize_first` function to pass the first two cases. // Step 2. Apply the `capitalize_first` function to a vector of strings. // Ensure that it returns a vector of strings as well. From 95ccd92616ae79ba287cce221101e0bbe4f68cdc Mon Sep 17 00:00:00 2001 From: fiplox <56274824+fiplox@users.noreply.github.com> Date: Sat, 7 Nov 2020 14:01:39 +0100 Subject: [PATCH 080/282] feat(try_from_into): Add tests (#571) Co-authored-by: Volodymyr Patuta <6977238-fiplox@users.noreply.gitlab.com> --- exercises/conversions/try_from_into.rs | 93 ++++++++++++++++---------- 1 file changed, 56 insertions(+), 37 deletions(-) diff --git a/exercises/conversions/try_from_into.rs b/exercises/conversions/try_from_into.rs index b830c166..cd14daf7 100644 --- a/exercises/conversions/try_from_into.rs +++ b/exercises/conversions/try_from_into.rs @@ -4,7 +4,7 @@ // You can read more about it at https://doc.rust-lang.org/std/convert/trait.TryFrom.html use std::convert::{TryFrom, TryInto}; -#[derive(Debug)] +#[derive(Debug, PartialEq)] struct Color { red: u8, green: u8, @@ -25,22 +25,19 @@ struct Color { // Tuple implementation impl TryFrom<(i16, i16, i16)> for Color { type Error = String; - fn try_from(tuple: (i16, i16, i16)) -> Result { - } + fn try_from(tuple: (i16, i16, i16)) -> Result {} } // Array implementation impl TryFrom<[i16; 3]> for Color { type Error = String; - fn try_from(arr: [i16; 3]) -> Result { - } + fn try_from(arr: [i16; 3]) -> Result {} } // Slice implementation impl TryFrom<&[i16]> for Color { type Error = String; - fn try_from(slice: &[i16]) -> Result { - } + fn try_from(slice: &[i16]) -> Result {} } fn main() { @@ -66,71 +63,93 @@ mod tests { use super::*; #[test] - #[should_panic] fn test_tuple_out_of_range_positive() { - let _ = Color::try_from((256, 1000, 10000)).unwrap(); + assert!(Color::try_from((256, 1000, 10000)).is_err()); } #[test] - #[should_panic] fn test_tuple_out_of_range_negative() { - let _ = Color::try_from((-1, -10, -256)).unwrap(); + assert!(Color::try_from((-1, -10, -256)).is_err()); + } + #[test] + fn test_tuple_sum() { + assert!(Color::try_from((-1, 255, 255)).is_err()); } #[test] fn test_tuple_correct() { - let c: Color = (183, 65, 14).try_into().unwrap(); - assert_eq!(c.red, 183); - assert_eq!(c.green, 65); - assert_eq!(c.blue, 14); + let c: Result = (183, 65, 14).try_into(); + assert_eq!( + c, + Ok(Color { + red: 183, + green: 65, + blue: 14 + }) + ); } - #[test] - #[should_panic] fn test_array_out_of_range_positive() { - let _: Color = [1000, 10000, 256].try_into().unwrap(); + let c: Color = [1000, 10000, 256].try_into(); + assert!(c.is_err()); } #[test] - #[should_panic] fn test_array_out_of_range_negative() { - let _: Color = [-10, -256, -1].try_into().unwrap(); + let c: Color = [-10, -256, -1].try_into(); + assert!(c.is_err()); } #[test] + fn test_array_sum() { + let c: Color = [-1, 255, 255].try_into(); + assert!(c.is_err()); + } + #[test] + #[test] fn test_array_correct() { - let c: Color = [183, 65, 14].try_into().unwrap(); - assert_eq!(c.red, 183); - assert_eq!(c.green, 65); - assert_eq!(c.blue, 14); + let c: Result = [183, 65, 14].try_into(); + assert_eq!( + c, + Ok(Color { + red: 183, + green: 65, + blue: 14 + }) + ); } - #[test] - #[should_panic] fn test_slice_out_of_range_positive() { let arr = [10000, 256, 1000]; - let _ = Color::try_from(&arr[..]).unwrap(); + assert!(Color::try_from(&arr[..]).is_err()); } #[test] - #[should_panic] fn test_slice_out_of_range_negative() { let arr = [-256, -1, -10]; - let _ = Color::try_from(&arr[..]).unwrap(); + assert!(Color::try_from(&arr[..]).is_err()); + } + #[test] + fn test_slice_sum() { + let arr = [-1, 255, 255]; + assert!(Color::try_from(&arr[..]).is_err()); } #[test] fn test_slice_correct() { let v = vec![183, 65, 14]; - let c = Color::try_from(&v[..]).unwrap(); - assert_eq!(c.red, 183); - assert_eq!(c.green, 65); - assert_eq!(c.blue, 14); + let c: Result = Color::try_from(&v[..]); + assert_eq!( + c, + Ok(Color { + red: 183, + green: 65, + blue: 14 + }) + ); } #[test] - #[should_panic] fn test_slice_excess_length() { let v = vec![0, 0, 0, 0]; - let _ = Color::try_from(&v[..]).unwrap(); + assert!(Color::try_from(&v[..]).is_err()); } #[test] - #[should_panic] fn test_slice_insufficient_length() { let v = vec![0, 0]; - let _ = Color::try_from(&v[..]).unwrap(); + assert!(Color::try_from(&v[..]).is_err()); } } From 964b2a331de2c98c1038fd859ac7e7c0e956236a Mon Sep 17 00:00:00 2001 From: mokou Date: Sat, 7 Nov 2020 14:21:10 +0100 Subject: [PATCH 081/282] release: 4.2.0 --- CHANGELOG.md | 21 +++++++++++++++++++++ Cargo.lock | 2 +- Cargo.toml | 2 +- README.md | 2 +- 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d156aa6..d58d4e6b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,24 @@ + +## 4.2.0 (2020-11-07) + +#### Features + +* Add HashMap exercises ([633c00cf](https://github.com/rust-lang/rustlings/commit/633c00cf8071e1e82959a3010452a32f34f29fc9)) +* Add Vec exercises ([0c12fa31](https://github.com/rust-lang/rustlings/commit/0c12fa31c57c03c6287458a0a8aca7afd057baf6)) +* **primitive_types6:** Add a test (#548) ([2b1fb2b7](https://github.com/rust-lang/rustlings/commit/2b1fb2b739bf9ad8d6b7b12af25fee173011bfc4)) +* **try_from_into:** Add tests (#571) ([95ccd926](https://github.com/rust-lang/rustlings/commit/95ccd92616ae79ba287cce221101e0bbe4f68cdc)) + +#### Bug Fixes + +* log error output when inotify limit is exceeded ([d61b4e5a](https://github.com/rust-lang/rustlings/commit/d61b4e5a13b44d72d004082f523fa1b6b24c1aca)) +* more unique temp_file ([5643ef05](https://github.com/rust-lang/rustlings/commit/5643ef05bc81e4a840e9456f4406a769abbe1392)) +* **installation:** Update the MinRustVersion ([21bfb2d4](https://github.com/rust-lang/rustlings/commit/21bfb2d4777429c87d8d3b5fbf0ce66006dcd034)) +* **iterators2:** Update description (#578) ([197d3a3d](https://github.com/rust-lang/rustlings/commit/197d3a3d8961b2465579218a6749b2b2cefa8ddd)) +* **primitive_types6:** + * remove 'unused doc comment' warning ([472d8592](https://github.com/rust-lang/rustlings/commit/472d8592d65c8275332a20dfc269e7ac0d41bc88)) + * missing comma in test ([4fb230da](https://github.com/rust-lang/rustlings/commit/4fb230daf1251444fcf29e085cee222a91f8a37e)) +* **quiz3:** Second test is for odd numbers, not even. (#553) ([18e0bfef](https://github.com/rust-lang/rustlings/commit/18e0bfef1de53071e353ba1ec5837002ff7290e6)) + ## 4.1.0 (2020-10-05) diff --git a/Cargo.lock b/Cargo.lock index cdc1af35..9f90e0a1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -592,7 +592,7 @@ dependencies = [ [[package]] name = "rustlings" -version = "4.1.0" +version = "4.2.0" dependencies = [ "assert_cmd 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)", "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index 68142845..ebce25eb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rustlings" -version = "4.1.0" +version = "4.2.0" authors = ["Marisa ", "Carol (Nichols || Goulding) "] edition = "2018" diff --git a/README.md b/README.md index 75a403f5..59ee6328 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ Basically: Clone the repository, checkout to the latest tag, run `cargo install` ```bash git clone https://github.com/rust-lang/rustlings cd rustlings -git checkout tags/4.1.0 # or whatever the latest version is (find out at https://github.com/rust-lang/rustlings/releases/latest) +git checkout tags/4.2.0 # or whatever the latest version is (find out at https://github.com/rust-lang/rustlings/releases/latest) cargo install --force --path . ``` From 9334783da31d821cc59174fbe8320df95828926c Mon Sep 17 00:00:00 2001 From: Brock <58987761+13r0ck@users.noreply.github.com> Date: Sun, 8 Nov 2020 02:31:45 -0700 Subject: [PATCH 082/282] fix(structs1): Adjust wording (#573) Co-authored-by: fmoko --- info.toml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/info.toml b/info.toml index c52702f7..cc12c99d 100644 --- a/info.toml +++ b/info.toml @@ -225,12 +225,13 @@ name = "structs1" path = "exercises/structs/structs1.rs" mode = "test" hint = """ -Rust has more than one type of struct. Both variants are used to package related data together. -On the one hand, there are normal, or classic, structs. These are named collections of related data stored in fields. -The other variant is tuple structs. Basically just named tuples. -In this exercise you need to implement one of each kind. +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 structs. These don't have and fields and are useful for generics. -Read more about structs in The Book: https://doc.rust-lang.org/stable/book/ch05-00-structs.html""" +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""" [[exercises]] name = "structs2" From 96347df9df294f01153b29d9ad4ba361f665c755 Mon Sep 17 00:00:00 2001 From: JP Date: Sun, 8 Nov 2020 19:30:40 +0100 Subject: [PATCH 083/282] fix(try_from_into): Update description (#584) Description update --- exercises/conversions/try_from_into.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/exercises/conversions/try_from_into.rs b/exercises/conversions/try_from_into.rs index cd14daf7..38ce2db7 100644 --- a/exercises/conversions/try_from_into.rs +++ b/exercises/conversions/try_from_into.rs @@ -15,12 +15,12 @@ struct Color { // Your task is to complete this implementation // and return an Ok result of inner type Color. -// You need create implementation for a tuple of three integer, -// an array of three integer and slice of integer. +// You need to create an implementation for a tuple of three integers, +// an array of three integers and a slice of integers. // -// Note, that implementation for tuple and array will be checked at compile-time, -// but slice implementation need check slice length! -// Also note, that chunk of correct rgb color must be integer in range 0..=255. +// Note that the implementation for tuple and array will be checked at compile time, +// but the slice implementation needs to check the slice length! +// Also note that correct RGB color values must be integers in the 0..=255 range. // Tuple implementation impl TryFrom<(i16, i16, i16)> for Color { From 838f9f30083d0b23fd67503dcf0fbeca498e6647 Mon Sep 17 00:00:00 2001 From: Caleb Webber Date: Tue, 10 Nov 2020 12:36:19 -0500 Subject: [PATCH 084/282] feat: add "rustlings list" command --- src/main.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main.rs b/src/main.rs index d0299e33..d04ad8f6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -54,6 +54,11 @@ fn main() { .about("Returns a hint for the current exercise") .arg(Arg::with_name("name").required(true).index(1)), ) + .subcommand( + SubCommand::with_name("list") + .alias("l") + .about("Lists the exercises available in rustlings") + ) .get_matches(); if matches.subcommand_name().is_none() { @@ -88,6 +93,9 @@ fn main() { let exercises = toml::from_str::(toml_str).unwrap().exercises; let verbose = matches.is_present("nocapture"); + if matches.subcommand_matches("list").is_some() { + exercises.iter().for_each(|e| println!("{}", e.name)); + } if let Some(ref matches) = matches.subcommand_matches("run") { let name = matches.value_of("name").unwrap(); From fa9f522b7f043d7ef73a39f003a9272dfe72c4f4 Mon Sep 17 00:00:00 2001 From: Brock <58987761+13r0ck@users.noreply.github.com> Date: Wed, 11 Nov 2020 15:06:14 -0700 Subject: [PATCH 085/282] feat: Crab? (#586) Crab? --- src/main.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/main.rs b/src/main.rs index d04ad8f6..35f8df4d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -138,6 +138,26 @@ fn main() { emoji = Emoji("πŸŽ‰", "β˜…") ); println!(); + println!("+----------------------------------------------------+"); + println!("| You made it to the Fe-nish line! |"); + println!("+-------------------------- ------------------------+"); + println!(" \\/ "); + println!(" β–’β–’ β–’β–’β–’β–’β–’β–’β–’β–’ β–’β–’β–’β–’β–’β–’β–’β–’ β–’β–’ "); + println!(" β–’β–’β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’β–’β–’ "); + println!(" β–’β–’β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’β–’β–’ "); + println!(" β–‘β–‘β–’β–’β–’β–’β–‘β–‘β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’β–‘β–‘β–’β–’β–’β–’ "); + println!(" β–“β–“β–“β–“β–“β–“β–“β–“ β–“β–“ β–“β–“β–ˆβ–ˆ β–“β–“ β–“β–“β–ˆβ–ˆ β–“β–“ β–“β–“β–“β–“β–“β–“β–“β–“ "); + println!(" β–’β–’β–’β–’ β–’β–’ β–ˆβ–ˆβ–ˆβ–ˆ β–’β–’ β–ˆβ–ˆβ–ˆβ–ˆ β–’β–’β–‘β–‘ β–’β–’β–’β–’ "); + println!(" β–’β–’ β–’β–’β–’β–’β–’β–’ β–’β–’β–’β–’β–’β–’ β–’β–’β–’β–’β–’β–’ β–’β–’ "); + println!(" β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–“β–“β–“β–“β–“β–“β–’β–’β–’β–’β–’β–’β–’β–’β–“β–“β–’β–’β–“β–“β–’β–’β–’β–’β–’β–’β–’β–’ "); + println!(" β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’ "); + println!(" β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–ˆβ–ˆβ–’β–’β–’β–’β–’β–’β–ˆβ–ˆβ–’β–’β–’β–’β–’β–’β–’β–’β–’β–’ "); + println!(" β–’β–’ β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–’β–’β–’β–’β–’β–’β–’β–’β–’β–’ β–’β–’ "); + println!(" β–’β–’ β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’ β–’β–’ "); + println!(" β–’β–’ β–’β–’ β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’ β–’β–’ β–’β–’ "); + println!(" β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’ "); + println!(" β–’β–’ β–’β–’ β–’β–’ β–’β–’ "); + println!(); println!("We hope you enjoyed learning about the various aspects of Rust!"); println!("If you noticed any issues, please don't hesitate to report them to our repo."); println!("You can also contribute your own exercises to help the greater community!"); From 4f4cfcf3c36c8718c7c170c9c3a6935e6ef0618c Mon Sep 17 00:00:00 2001 From: Wei Hu Date: Wed, 11 Nov 2020 21:02:00 -0800 Subject: [PATCH 086/282] fix(try_from_into): type error --- exercises/conversions/try_from_into.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/exercises/conversions/try_from_into.rs b/exercises/conversions/try_from_into.rs index 38ce2db7..897b364e 100644 --- a/exercises/conversions/try_from_into.rs +++ b/exercises/conversions/try_from_into.rs @@ -88,17 +88,17 @@ mod tests { } #[test] fn test_array_out_of_range_positive() { - let c: Color = [1000, 10000, 256].try_into(); + let c: Result = [1000, 10000, 256].try_into(); assert!(c.is_err()); } #[test] fn test_array_out_of_range_negative() { - let c: Color = [-10, -256, -1].try_into(); + let c: Result = [-10, -256, -1].try_into(); assert!(c.is_err()); } #[test] fn test_array_sum() { - let c: Color = [-1, 255, 255].try_into(); + let c: Result = [-1, 255, 255].try_into(); assert!(c.is_err()); } #[test] From d6d57bfbb8190edef5fcd7ecb4a20c8944ca87b1 Mon Sep 17 00:00:00 2001 From: fmoko Date: Thu, 12 Nov 2020 09:50:39 +0100 Subject: [PATCH 087/282] docs: Remove buildkite badge from README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 59ee6328..fd45d945 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![All Contributors](https://img.shields.io/badge/all_contributors-68-orange.svg?style=flat-square)](#contributors-) -# rustlings πŸ¦€β€οΈ [![Build status](https://badge.buildkite.com/7af93d81dc522c67a1ec8e33ff5705861b1cb36360b774807f.svg)](https://buildkite.com/mokou/rustlings) +# rustlings πŸ¦€β€οΈ Greetings and welcome to `rustlings`. This project contains small exercises to get you used to reading and writing Rust code. This includes reading and responding to compiler messages! From af7ad27f89d3e981076705cd7dd36ee0e6dcaaa6 Mon Sep 17 00:00:00 2001 From: fmoko Date: Thu, 12 Nov 2020 09:50:55 +0100 Subject: [PATCH 088/282] chore: Remove buildkite build file --- buildkite.yml | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 buildkite.yml diff --git a/buildkite.yml b/buildkite.yml deleted file mode 100644 index 91a0753c..00000000 --- a/buildkite.yml +++ /dev/null @@ -1,5 +0,0 @@ -steps: - - label: "Test with stable" - command: rustup run stable cargo test - - label: "Test with beta" - command: rustup run beta cargo test From 9b6c629397b24b944f484f5b2bbd8144266b5695 Mon Sep 17 00:00:00 2001 From: Jacob Tinkhauser <75188781+tinkhauser@users.noreply.github.com> Date: Sun, 29 Nov 2020 01:35:14 +0000 Subject: [PATCH 089/282] fix(vec1): Have test compare every element in a and v The previous test would stop comparing elements in array a and vec v upon reaching the last element of either. This resulted in the test passing even if v did not contain all the elements in a. This change to the test fixes that bug and should only pass if all the elements in a and v are present and equal. --- exercises/collections/vec1.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/collections/vec1.rs b/exercises/collections/vec1.rs index ac3d9f1a..f6bc837c 100644 --- a/exercises/collections/vec1.rs +++ b/exercises/collections/vec1.rs @@ -20,6 +20,6 @@ mod tests { #[test] fn test_array_and_vec_similarity() { let (a, v) = array_and_vec(); - assert!(a.iter().zip(v.iter()).all(|(x, y)| x == y)); + assert_eq!(a, v[..]); } } From 04f1d079aa42a2f49af694bc92c67d731d31a53f Mon Sep 17 00:00:00 2001 From: Christos Kontas Date: Thu, 3 Dec 2020 17:48:30 +0100 Subject: [PATCH 090/282] feat(try_from_into): remove duplicate annotation --- exercises/conversions/try_from_into.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/exercises/conversions/try_from_into.rs b/exercises/conversions/try_from_into.rs index 897b364e..e405c3f4 100644 --- a/exercises/conversions/try_from_into.rs +++ b/exercises/conversions/try_from_into.rs @@ -102,7 +102,6 @@ mod tests { assert!(c.is_err()); } #[test] - #[test] fn test_array_correct() { let c: Result = [183, 65, 14].try_into(); assert_eq!( From 033bf1198fc8bfce1b570e49da7cde010aa552e3 Mon Sep 17 00:00:00 2001 From: JuliaCao Date: Mon, 7 Dec 2020 06:37:19 -0800 Subject: [PATCH 091/282] feat: match exercise order to book chapters (#541) Added exercise to book chapter mapping table to exercise README --- exercises/README.md | 23 ++ info.toml | 634 ++++++++++++++++++++------------------------ 2 files changed, 304 insertions(+), 353 deletions(-) create mode 100644 exercises/README.md diff --git a/exercises/README.md b/exercises/README.md new file mode 100644 index 00000000..725edd7b --- /dev/null +++ b/exercises/README.md @@ -0,0 +1,23 @@ +# Exercise to Book Chapter mapping + +| Exercise | Book Chapter | +|------------------------|--------------| +| variables | Β§3.1 | +| functions | Β§3.3 | +| if | Β§3.5 | +| move_semantics | Β§4.1 | +| primitive_types | Β§4.3 | +| structs | Β§5.1 | +| enums | Β§6 | +| modules | Β§7.2 | +| strings | Β§8.2 | +| error_handling | Β§9 | +| generics | Β§10 | +| option | Β§10.1 | +| traits | Β§10.2 | +| tests | Β§11.1 | +| standard_library_types | Β§13.2 | +| threads | Β§16.1 | +| macros | Β§19.6 | +| clippy | n/a | +| conversions | n/a | diff --git a/info.toml b/info.toml index cc12c99d..1b2eec21 100644 --- a/info.toml +++ b/info.toml @@ -71,31 +71,6 @@ Read more about constants under 'Differences Between Variables and Constants' in https://doc.rust-lang.org/book/ch03-01-variables-and-mutability.html#differences-between-variables-and-constants """ -# IF - -[[exercises]] -name = "if1" -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 -- Each condition is followed by a `{}` block.""" - -[[exercises]] -name = "if2" -path = "exercises/if/if2.rs" -mode = "test" -hint = """ -For that first compiler error, it's important in Rust that each conditional -block return the same type! To get the tests passing, you will need a couple -conditions checking different input values.""" - # FUNCTIONS [[exercises]] @@ -146,6 +121,31 @@ 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`""" +# IF + +[[exercises]] +name = "if1" +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 +- Each condition is followed by a `{}` block.""" + +[[exercises]] +name = "if2" +path = "exercises/if/if2.rs" +mode = "test" +hint = """ +For that first compiler error, it's important in Rust that each conditional +block return the same type! To get the tests passing, you will need a couple +conditions checking different input values.""" + # TEST 1 [[exercises]] @@ -154,6 +154,62 @@ path = "exercises/quiz1.rs" mode = "test" hint = "No hints this time ;)" +# MOVE SEMANTICS + +[[exercises]] +name = "move_semantics1" +path = "exercises/move_semantics/move_semantics1.rs" +mode = "compile" +hint = """ +So you've got the "cannot borrow immutable local variable `vec1` as mutable" error on line 13, +right? The fix for this is going to be adding one keyword, and the addition is NOT on line 13 +where the error is.""" + +[[exercises]] +name = "move_semantics2" +path = "exercises/move_semantics/move_semantics2.rs" +mode = "compile" +hint = """ +So `vec0` is being *moved* into the function `fill_vec` when we call it on +line 10, which means it gets dropped at the end of `fill_vec`, which means we +can't use `vec0` again on line 13 (or anywhere else in `main` after the +`fill_vec` call for that matter). We could fix this in a few ways, try them +all! +1. Make another, separate version of the data that's in `vec0` and pass that + to `fill_vec` instead. +2. Make `fill_vec` borrow its argument instead of taking ownership of it, + and then copy the data within the function in order to return an owned + `Vec` +3. Make `fill_vec` *mutably* borrow its argument (which will need to be + mutable), modify it directly, then not return anything. Then you can get rid + of `vec1` entirely -- note that this will change what gets printed by the + first `println!`""" + +[[exercises]] +name = "move_semantics3" +path = "exercises/move_semantics/move_semantics3.rs" +mode = "compile" +hint = """ +The difference between this one and the previous ones is that the first line +of `fn fill_vec` that had `let mut vec = vec;` is no longer there. You can, +instead of adding that line back, add `mut` in one place that will change +an existing binding to be a mutable binding instead of an immutable one :)""" + +[[exercises]] +name = "move_semantics4" +path = "exercises/move_semantics/move_semantics4.rs" +mode = "compile" +hint = """ +Stop reading whenever you feel like you have enough direction :) Or try +doing one step and then fixing the compiler errors that result! +So the end goal is to: + - get rid of the first line in main that creates the new vector + - so then `vec0` doesn't exist, so we can't pass it to `fill_vec` + - we don't want to pass anything to `fill_vec`, so its signature should + reflect that it does not take any arguments + - since we're not creating a new vec in `main` anymore, we need to create + a new vec in `fill_vec`, similarly to the way we did in `main`""" + # PRIMITIVE TYPES [[exercises]] @@ -255,6 +311,51 @@ For calculate_transport_fees: Bigger is more expensive usually, we don't have si 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 + +[[exercises]] +name = "enums1" +path = "exercises/enums/enums1.rs" +mode = "compile" +hint = """ +Hint: The declaration of the enumeration type has not been defined yet.""" + +[[exercises]] +name = "enums2" +path = "exercises/enums/enums2.rs" +mode = "compile" +hint = """ +Hint: you can create enumerations that have different variants with different types +such as no data, anonymous structs, a single string, tuples, ...etc""" + +[[exercises]] +name = "enums3" +path = "exercises/enums/enums3.rs" +mode = "test" +hint = "No hints this time ;)" + +# MODULES + +[[exercises]] +name = "modules1" +path = "exercises/modules/modules1.rs" +mode = "compile" +hint = """ +Everything is private in Rust by default-- but there's a keyword we can use +to make something public! The compiler error should point to the thing that +needs to be public.""" + +[[exercises]] +name = "modules2" +path = "exercises/modules/modules2.rs" +mode = "compile" +hint = """ +The delicious_snacks module is trying to present an external +interface (the `fruit` and `veggie` constants) that is different than +its internal structure (the `fruits` and `veggies` modules and +associated constants). It's almost there except for one keyword missing for +each constant.""" + # STRINGS [[exercises]] @@ -286,248 +387,6 @@ path = "exercises/quiz2.rs" mode = "compile" hint = "No hints this time ;)" -# ENUMS - -[[exercises]] -name = "enums1" -path = "exercises/enums/enums1.rs" -mode = "compile" -hint = """ -Hint: The declaration of the enumeration type has not been defined yet.""" - -[[exercises]] -name = "enums2" -path = "exercises/enums/enums2.rs" -mode = "compile" -hint = """ -Hint: you can create enumerations that have different variants with different types -such as no data, anonymous structs, a single string, tuples, ...etc""" - -[[exercises]] -name = "enums3" -path = "exercises/enums/enums3.rs" -mode = "test" -hint = "No hints this time ;)" - -# TESTS - -[[exercises]] -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 :)""" - -[[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!""" - -[[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())`.""" - -# TEST 3 - -[[exercises]] -name = "quiz3" -path = "exercises/quiz3.rs" -mode = "test" -hint = "No hints this time ;)" - -# MODULES - -[[exercises]] -name = "modules1" -path = "exercises/modules/modules1.rs" -mode = "compile" -hint = """ -Everything is private in Rust by default-- but there's a keyword we can use -to make something public! The compiler error should point to the thing that -needs to be public.""" - -[[exercises]] -name = "modules2" -path = "exercises/modules/modules2.rs" -mode = "compile" -hint = """ -The delicious_snacks module is trying to present an external -interface (the `fruit` and `veggie` constants) that is different than -its internal structure (the `fruits` and `veggies` modules and -associated constants). It's almost there except for one keyword missing for -each constant.""" - -# COLLECTIONS - -[[exercises]] -name = "collections1" -path = "exercises/collections/vec1.rs" -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. - -2. The second way, which is simpler is to use the `vec![]` macro and - 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. -""" - -[[exercises]] -name = "collections2" -path = "exercises/collections/vec2.rs" -mode = "test" -hint = """ -Hint 1: `i` is each element from the Vec as they are being iterated. - Can you try multiplying this? - -Hint 2: Check the suggestion from the compiler error ;) -""" - -[[exercises]] -name = "collections3" -path = "exercises/collections/hashmap1.rs" -mode = "test" -hint = """ -Hint 1: Take a look at the return type of the function to figure out - 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. -""" - -[[exercises]] -name = "collections4" -path = "exercises/collections/hashmap2.rs" -mode = "test" -hint = """ -Use the `entry()` and `or_insert()` methods of `HashMap` to achieve this. - -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 -""" - -# MACROS - -[[exercises]] -name = "macros1" -path = "exercises/macros/macros1.rs" -mode = "compile" -hint = """ -When you call a macro, you need to add something special compared to a -regular function call. If you're stuck, take a look at what's inside -`my_macro`.""" - -[[exercises]] -name = "macros2" -path = "exercises/macros/macros2.rs" -mode = "compile" -hint = """ -Macros don't quite play by the same rules as the rest of Rust, in terms of -what's available where. - -Unlike other things in Rust, the order of "where you define a macro" versus -"where you use it" actually matters.""" - -[[exercises]] -name = "macros3" -path = "exercises/macros/macros3.rs" -mode = "compile" -hint = """ -In order to use a macro outside of its module, you need to do something -special to the module to lift the macro out into its parent. - -The same trick also works on "extern crate" statements for crates that have -exported macros, if you've seen any of those around.""" - -[[exercises]] -name = "macros4" -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.""" -# TEST 4 - -[[exercises]] -name = "quiz4" -path = "exercises/quiz4.rs" -mode = "test" -hint = "No hints this time ;)" - -# MOVE SEMANTICS - -[[exercises]] -name = "move_semantics1" -path = "exercises/move_semantics/move_semantics1.rs" -mode = "compile" -hint = """ -So you've got the "cannot borrow immutable local variable `vec1` as mutable" error on line 13, -right? The fix for this is going to be adding one keyword, and the addition is NOT on line 13 -where the error is.""" - -[[exercises]] -name = "move_semantics2" -path = "exercises/move_semantics/move_semantics2.rs" -mode = "compile" -hint = """ -So `vec0` is being *moved* into the function `fill_vec` when we call it on -line 10, which means it gets dropped at the end of `fill_vec`, which means we -can't use `vec0` again on line 13 (or anywhere else in `main` after the -`fill_vec` call for that matter). We could fix this in a few ways, try them -all! -1. Make another, separate version of the data that's in `vec0` and pass that - to `fill_vec` instead. -2. Make `fill_vec` borrow its argument instead of taking ownership of it, - and then copy the data within the function in order to return an owned - `Vec` -3. Make `fill_vec` *mutably* borrow its argument (which will need to be - mutable), modify it directly, then not return anything. Then you can get rid - of `vec1` entirely -- note that this will change what gets printed by the - first `println!`""" - -[[exercises]] -name = "move_semantics3" -path = "exercises/move_semantics/move_semantics3.rs" -mode = "compile" -hint = """ -The difference between this one and the previous ones is that the first line -of `fn fill_vec` that had `let mut vec = vec;` is no longer there. You can, -instead of adding that line back, add `mut` in one place that will change -an existing binding to be a mutable binding instead of an immutable one :)""" - -[[exercises]] -name = "move_semantics4" -path = "exercises/move_semantics/move_semantics4.rs" -mode = "compile" -hint = """ -Stop reading whenever you feel like you have enough direction :) Or try -doing one step and then fixing the compiler errors that result! -So the end goal is to: - - get rid of the first line in main that creates the new vector - - so then `vec0` doesn't exist, so we can't pass it to `fill_vec` - - we don't want to pass anything to `fill_vec`, so its signature should - reflect that it does not take any arguments - - since we're not creating a new vec in `main` anymore, we need to create - a new vec in `fill_vec`, similarly to the way we did in `main`""" - # ERROR HANDLING [[exercises]] @@ -607,6 +466,40 @@ get a warning if you don't handle a `Result` that you get in your function. Read more about that in the `std::result` module docs: https://doc.rust-lang.org/std/result/#results-must-be-used""" +# Generics + +[[exercises]] +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. +You need to tell the compiler what type we are pushing onto this vector.""" + +[[exercises]] +name = "generics2" +path = "exercises/generics/generics2.rs" +mode = "test" +hint = """ +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 +""" + +[[exercises]] +name = "generics3" +path = "exercises/generics/generics3.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;" + +This is definitely harder than the last two exercises! You need to think about not only making the +ReportCard struct generic, but also the correct property - you will need to change the implementation +of the struct slightly too...you can do it! +""" + # OPTIONS / RESULTS [[exercises]] @@ -649,21 +542,67 @@ hint = """ 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 :)""" -# CLIPPY +# TRAITS [[exercises]] -name = "clippy1" -path = "exercises/clippy/clippy1.rs" -mode = "clippy" +name = "traits1" +path = "exercises/traits/traits1.rs" +mode = "test" hint = """ -Floating point calculations are usually imprecise, so asking if two values are exactly equal is asking for trouble""" +A discussion about Traits in Rust can be found at: +https://doc.rust-lang.org/book/ch10-02-traits.html +""" [[exercises]] -name = "clippy2" -path = "exercises/clippy/clippy2.rs" -mode = "clippy" +name = "traits2" +path = "exercises/traits/traits2.rs" +mode = "test" hint = """ -`for` loops over Option values are more clearly expressed as an `if let`""" +Notice how the trait takes ownership of 'self',and returns `Self'. +Try mutating the incoming string vector. + +Vectors provide suitable methods for adding an element at the end. See +the documentation at: https://doc.rust-lang.org/std/vec/struct.Vec.html""" + +# TESTS + +[[exercises]] +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 :)""" + +[[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!""" + +[[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())`.""" + +# TEST 3 + +[[exercises]] +name = "quiz3" +path = "exercises/quiz3.rs" +mode = "test" +hint = "No hints this time ;)" # STANDARD LIBRARY TYPES @@ -697,27 +636,6 @@ inside the loop but still in the main thread. `child_numbers` should be a clone of the Arc of the numbers instead of a thread-local copy of the numbers.""" -[[exercises]] -name = "iterators1" -path = "exercises/standard_library_types/iterators1.rs" -mode = "compile" -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: -https://doc.rust-lang.org/std/vec/struct.Vec.html. - - -Step 2 & step 2.1: -Very similar to the lines above and below. You've got this! - - -Step 3: -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. -""" - [[exercises]] name = "iterators2" path = "exercises/standard_library_types/iterators2.rs" @@ -761,62 +679,6 @@ 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.""" -# TRAITS - -[[exercises]] -name = "traits1" -path = "exercises/traits/traits1.rs" -mode = "test" -hint = """ -A discussion about Traits in Rust can be found at: -https://doc.rust-lang.org/book/ch10-02-traits.html -""" - -[[exercises]] -name = "traits2" -path = "exercises/traits/traits2.rs" -mode = "test" -hint = """ -Notice how the trait takes ownership of 'self',and returns `Self'. -Try mutating the incoming string vector. - -Vectors provide suitable methods for adding an element at the end. See -the documentation at: https://doc.rust-lang.org/std/vec/struct.Vec.html""" - -# Generics - -[[exercises]] -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. -You need to tell the compiler what type we are pushing onto this vector.""" - -[[exercises]] -name = "generics2" -path = "exercises/generics/generics2.rs" -mode = "test" -hint = """ -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 -""" - -[[exercises]] -name = "generics3" -path = "exercises/generics/generics3.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;" - -This is definitely harder than the last two exercises! You need to think about not only making the -ReportCard struct generic, but also the correct property - you will need to change the implementation -of the struct slightly too...you can do it! -""" - # THREADS [[exercises]] @@ -856,6 +718,72 @@ If you've learned from the sample solutions, I encourage you to come back to this exercise and try it again in a few days to reinforce what you've learned :)""" +# MACROS + +[[exercises]] +name = "macros1" +path = "exercises/macros/macros1.rs" +mode = "compile" +hint = """ +When you call a macro, you need to add something special compared to a +regular function call. If you're stuck, take a look at what's inside +`my_macro`.""" + +[[exercises]] +name = "macros2" +path = "exercises/macros/macros2.rs" +mode = "compile" +hint = """ +Macros don't quite play by the same rules as the rest of Rust, in terms of +what's available where. + +Unlike other things in Rust, the order of "where you define a macro" versus +"where you use it" actually matters.""" + +[[exercises]] +name = "macros3" +path = "exercises/macros/macros3.rs" +mode = "compile" +hint = """ +In order to use a macro outside of its module, you need to do something +special to the module to lift the macro out into its parent. + +The same trick also works on "extern crate" statements for crates that have +exported macros, if you've seen any of those around.""" + +[[exercises]] +name = "macros4" +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.""" + +# TEST 4 + +[[exercises]] +name = "quiz4" +path = "exercises/quiz4.rs" +mode = "test" +hint = "No hints this time ;)" + +# CLIPPY + +[[exercises]] +name = "clippy1" +path = "exercises/clippy/clippy1.rs" +mode = "clippy" +hint = """ +Floating point calculations are usually imprecise, so asking if two values are exactly equal is asking for trouble""" + +[[exercises]] +name = "clippy2" +path = "exercises/clippy/clippy2.rs" +mode = "clippy" +hint = """ +`for` loops over Option values are more clearly expressed as an `if let`""" + # TYPE CONVERSIONS [[exercises]] From 30644c9a062b825c0ea89435dc59f0cad86b110e Mon Sep 17 00:00:00 2001 From: Peter N Date: Tue, 8 Dec 2020 06:08:25 -0300 Subject: [PATCH 092/282] fix: gives a bit more context to magic number --- exercises/threads/threads1.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/exercises/threads/threads1.rs b/exercises/threads/threads1.rs index 1785e8ce..b475b4a1 100644 --- a/exercises/threads/threads1.rs +++ b/exercises/threads/threads1.rs @@ -1,7 +1,8 @@ // threads1.rs // Make this compile! Execute `rustlings hint threads1` for hints :) // The idea is the thread spawned on line 21 is completing jobs while the main thread is -// monitoring progress until 10 jobs are completed. If you see 6 lines +// monitoring progress until 10 jobs are completed. Because of the difference between the +// spawned threads' sleep time, and the waiting threads sleep time, when you see 6 lines // of "waiting..." and the program ends without timing out when running, // you've got it :) From 26110da7cadc4ab7614730c2d0b1e514a2763d3d Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Tue, 8 Dec 2020 10:12:57 +0100 Subject: [PATCH 093/282] docs: add pcn as a contributor * docs: update README.md [skip ci] * docs: update .all-contributorsrc [skip ci] Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com> --- .all-contributorsrc | 9 +++++++++ README.md | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index 84b2365e..388bf5ff 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -637,6 +637,15 @@ "contributions": [ "maintenance" ] + }, + { + "login": "pcn", + "name": "Peter N", + "avatar_url": "https://avatars2.githubusercontent.com/u/1056756?v=4", + "profile": "https://github.com/pcn", + "contributions": [ + "maintenance" + ] } ], "contributorsPerLine": 8, diff --git a/README.md b/README.md index fd45d945..49ceb2c9 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ![crab pet](https://i.imgur.com/LbZJgmm.gif) -[![All Contributors](https://img.shields.io/badge/all_contributors-68-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-69-orange.svg?style=flat-square)](#contributors-) # rustlings πŸ¦€β€οΈ @@ -233,6 +233,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Axel Viala

πŸ’»
Mohammed Sazid Al Rashid

πŸ–‹ πŸ’»
Caleb Webber

🚧 +
Peter N

🚧 From 90cfb6ff28377531bfc34acb70547bdb13374f6b Mon Sep 17 00:00:00 2001 From: JuliaCao Date: Sat, 12 Dec 2020 10:21:23 -0800 Subject: [PATCH 094/282] fix: added missing exercises to info.toml --- exercises/README.md | 1 + info.toml | 63 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) diff --git a/exercises/README.md b/exercises/README.md index 725edd7b..0c715247 100644 --- a/exercises/README.md +++ b/exercises/README.md @@ -10,6 +10,7 @@ | structs | Β§5.1 | | enums | Β§6 | | modules | Β§7.2 | +| collections | Β§8.1 | | strings | Β§8.2 | | error_handling | Β§9 | | generics | Β§10 | diff --git a/info.toml b/info.toml index 1b2eec21..f1fc3981 100644 --- a/info.toml +++ b/info.toml @@ -356,6 +356,52 @@ its internal structure (the `fruits` and `veggies` modules and associated constants). It's almost there except for one keyword missing for each constant.""" +# COLLECTIONS + +[[exercises]] +name = "collections1" +path = "exercises/collections/vec1.rs" +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. +2. The second way, which is simpler is to use the `vec![]` macro and + 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. +""" + +[[exercises]] +name = "collections2" +path = "exercises/collections/vec2.rs" +mode = "test" +hint = """ +Hint 1: `i` is each element from the Vec as they are being iterated. + Can you try multiplying this? +Hint 2: Check the suggestion from the compiler error ;) +""" + +[[exercises]] +name = "collections3" +path = "exercises/collections/hashmap1.rs" +mode = "test" +hint = """ +Hint 1: Take a look at the return type of the function to figure out + 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. +""" + +[[exercises]] +name = "collections4" +path = "exercises/collections/hashmap2.rs" +mode = "test" +hint = """ +Use the `entry()` and `or_insert()` methods of `HashMap` to achieve this. +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 +""" + # STRINGS [[exercises]] @@ -636,6 +682,23 @@ inside the loop but still in the main thread. `child_numbers` should be a clone of the Arc of the numbers instead of a thread-local copy of the numbers.""" +[[exercises]] +name = "iterators1" +path = "exercises/standard_library_types/iterators1.rs" +mode = "compile" +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: +https://doc.rust-lang.org/std/vec/struct.Vec.html. +Step 2 & step 2.1: +Very similar to the lines above and below. You've got this! +Step 3: +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. +""" + [[exercises]] name = "iterators2" path = "exercises/standard_library_types/iterators2.rs" From bcf14cf677adb3a38a3ac3ca53f3c69f61153025 Mon Sep 17 00:00:00 2001 From: seancad <47405611+seancad@users.noreply.github.com> Date: Tue, 15 Dec 2020 00:32:46 -0700 Subject: [PATCH 095/282] fix: update structs README --- exercises/structs/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/structs/README.md b/exercises/structs/README.md index afbc72c8..d2d7dc24 100644 --- a/exercises/structs/README.md +++ b/exercises/structs/README.md @@ -4,4 +4,4 @@ Rust has three struct types: a classic c struct, a tuple struct, and a unit stru #### Book Sections -- [Structures](https://doc.rust-lang.org/rust-by-example/custom_types/structs.html) +- [Structures](https://doc.rust-lang.org/book/ch05-01-defining-structs.html) From 4ac70a99aea688a629e5d7ef99bb8686fa7f6301 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Tue, 15 Dec 2020 08:33:47 +0100 Subject: [PATCH 096/282] docs: add seancad as a contributor * docs: update README.md [skip ci] * docs: update .all-contributorsrc [skip ci] Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com> --- .all-contributorsrc | 9 +++++++++ README.md | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index 388bf5ff..1549aa45 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -646,6 +646,15 @@ "contributions": [ "maintenance" ] + }, + { + "login": "seancad", + "name": "seancad", + "avatar_url": "https://avatars1.githubusercontent.com/u/47405611?v=4", + "profile": "https://github.com/seancad", + "contributions": [ + "maintenance" + ] } ], "contributorsPerLine": 8, diff --git a/README.md b/README.md index 49ceb2c9..7a2c94c6 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ![crab pet](https://i.imgur.com/LbZJgmm.gif) -[![All Contributors](https://img.shields.io/badge/all_contributors-69-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-70-orange.svg?style=flat-square)](#contributors-) # rustlings πŸ¦€β€οΈ @@ -234,6 +234,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Mohammed Sazid Al Rashid

πŸ–‹ πŸ’»
Caleb Webber

🚧
Peter N

🚧 +
seancad

🚧 From 0ef95947cc30482e63a7045be6cc2fb6f6dcb4cc Mon Sep 17 00:00:00 2001 From: Axel Viala Date: Sun, 27 Dec 2020 12:36:38 +0100 Subject: [PATCH 097/282] fix(functions2): Change signature to trigger precise error message: (#605) Now trigger this error: ``` error: expected type, found `)` --> exercises/functions/functions2.rs:10:16 | 10 | fn call_me(num:) { | ^ expected type ``` --- exercises/functions/functions2.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/functions/functions2.rs b/exercises/functions/functions2.rs index 108ba38b..5721a172 100644 --- a/exercises/functions/functions2.rs +++ b/exercises/functions/functions2.rs @@ -7,7 +7,7 @@ fn main() { call_me(3); } -fn call_me(num) { +fn call_me(num:) { for i in 0..num { println!("Ring! Call number {}", i + 1); } From 28020d0c54e795c465f59cb92954599de8834549 Mon Sep 17 00:00:00 2001 From: mokou Date: Tue, 29 Dec 2020 11:23:08 +0100 Subject: [PATCH 098/282] docs: Add note on uninstalling to README --- README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/README.md b/README.md index 7a2c94c6..9512ac5c 100644 --- a/README.md +++ b/README.md @@ -118,6 +118,24 @@ cargo uninstall rustlings rm -r rustlings/ # or on Windows: rmdir /s rustlings ``` +## Uninstalling Rustlings + +If you want to remove Rustlings from your system, there's two steps. First, you'll need to remove the exercises folder that the install script created +for you: + +``` bash +rm -rf rustlings # or your custom folder name, if you chose and or renamed it +``` + +Second, since Rustlings got installed via `cargo install`, it's only reasonable to assume that you can also remove it using Cargo, and +exactly that is the case. Run `cargo uninstall` to remove the `rustlings` binary: + +``` bash +cargo uninstall rustlings +``` + +Now you should be done! + ## Completion Rustlings isn't done; there are a couple of sections that are very experimental and don't have proper documentation. These include: From 44d39112ff122b29c9793fe52e605df1612c6490 Mon Sep 17 00:00:00 2001 From: mokou Date: Tue, 29 Dec 2020 11:34:52 +0100 Subject: [PATCH 099/282] feat: Rewrite default out text This has been in place for a long time now, before we had an install script, so it ended up repeating a bunch of the same things that the install script does automatically. I rewrote it so that it gives more helpful information about how you're supposed to do Rustlings. Hopefully this will reduce the number of "I started Rustlings and it gave me an error" issues (no offense to anyone who opened one of those, it was pretty unclear that it _wasn't_ an error). --- default_out.txt | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/default_out.txt b/default_out.txt index 05267591..44b7734c 100644 --- a/default_out.txt +++ b/default_out.txt @@ -1,19 +1,25 @@ Thanks for installing Rustlings! -Is this your first time? +Is this your first time? Don't worry, Rustlings was made for beginners! We are +going to teach you a lot of things about Rust, but before we can get +started, here's a couple of notes about how Rustlings operates: -Let's make sure you're up to speed: -- You have Rust installed, preferably via `rustup` -- You have `~/.cargo/bin` added to your PATH variable -- You have cloned this repository (https://github.com/rust-lang/rustlings) -- You have installed Rust language support for your editor -- You have locally installed the `rustlings` command by running an - installation script or manually executing: +1. The central concept behind Rustlings is that you solve exercises. These + exercises usually have some sort of syntax error in them, which will cause + them to fail compliation or testing. Sometimes there's a logic error instead + of a syntax error. No matter what error, it's your job to find it and fix it! + You'll know when you fixed it because then, the exercise will compile and + Rustlings will be able to move on to the next exercise. +2. If you run Rustlings in watch mode (which we recommend), it'll automatically + start with the first exercise. Don't get confused by an error message popping + up as soon as you run Rustlings! This is part of the exercise that you're + supposed to solve, so open the exercise file in an editor and start your + detective work! +3. If you're stuck on an exercise, there is a helpful hint you can view by typing + 'hint' (in watch mode), or running `rustlings hint myexercise`. +4. If an exercise doesn't make sense to you, feel free to open an issue on GitHub! + (https://github.com/rust-lang/rustlings/issues/new). We look at every issue, + and sometimes, other learners do too so you can help each other out! -cargo install --force --path . - -If you've done all of this (or even most of it), congrats! You're ready -to start working with Rust. - -To get started, run `rustlings watch` in order to get the first exercise. -Make sure to have your editor open! +Got all that? Great! To get started, run `rustlings watch` in order to get the first +exercise. Make sure to have your editor open! From a303d508cf0c5bc20bb50bd388b2545bf80672ac Mon Sep 17 00:00:00 2001 From: mokou Date: Tue, 29 Dec 2020 11:39:26 +0100 Subject: [PATCH 100/282] release: 4.3.0 --- CHANGELOG.md | 23 ++ Cargo.lock | 590 +++++++++++++++++++++++++-------------------------- Cargo.toml | 2 +- README.md | 2 +- src/main.rs | 2 +- 5 files changed, 320 insertions(+), 299 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d58d4e6b..3988826e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,26 @@ + +## 4.3.0 (2020-12-29) + +#### Features + +* Rewrite default out text ([44d39112](https://github.com/rust-lang/rustlings/commit/44d39112ff122b29c9793fe52e605df1612c6490)) +* match exercise order to book chapters (#541) ([033bf119](https://github.com/rust-lang/rustlings/commit/033bf1198fc8bfce1b570e49da7cde010aa552e3)) +* Crab? (#586) ([fa9f522b](https://github.com/rust-lang/rustlings/commit/fa9f522b7f043d7ef73a39f003a9272dfe72c4f4)) +* add "rustlings list" command ([838f9f30](https://github.com/rust-lang/rustlings/commit/838f9f30083d0b23fd67503dcf0fbeca498e6647)) +* **try_from_into:** remove duplicate annotation ([04f1d079](https://github.com/rust-lang/rustlings/commit/04f1d079aa42a2f49af694bc92c67d731d31a53f)) + +#### Bug Fixes + +* update structs README ([bcf14cf6](https://github.com/rust-lang/rustlings/commit/bcf14cf677adb3a38a3ac3ca53f3c69f61153025)) +* added missing exercises to info.toml ([90cfb6ff](https://github.com/rust-lang/rustlings/commit/90cfb6ff28377531bfc34acb70547bdb13374f6b)) +* gives a bit more context to magic number ([30644c9a](https://github.com/rust-lang/rustlings/commit/30644c9a062b825c0ea89435dc59f0cad86b110e)) +* **functions2:** Change signature to trigger precise error message: (#605) ([0ef95947](https://github.com/rust-lang/rustlings/commit/0ef95947cc30482e63a7045be6cc2fb6f6dcb4cc)) +* **structs1:** Adjust wording (#573) ([9334783d](https://github.com/rust-lang/rustlings/commit/9334783da31d821cc59174fbe8320df95828926c)) +* **try_from_into:** + * type error ([4f4cfcf3](https://github.com/rust-lang/rustlings/commit/4f4cfcf3c36c8718c7c170c9c3a6935e6ef0618c)) + * Update description (#584) ([96347df9](https://github.com/rust-lang/rustlings/commit/96347df9df294f01153b29d9ad4ba361f665c755)) +* **vec1:** Have test compare every element in a and v ([9b6c6293](https://github.com/rust-lang/rustlings/commit/9b6c629397b24b944f484f5b2bbd8144266b5695)) + ## 4.2.0 (2020-11-07) diff --git a/Cargo.lock b/Cargo.lock index 9f90e0a1..4a4313e7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,917 +4,915 @@ name = "aho-corasick" version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6f484ae0c99fec2e858eb6134949117399f222608d84cadb3f58c1f97c2364c" dependencies = [ - "memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr", ] [[package]] name = "ansi_term" version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" dependencies = [ - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8", ] [[package]] name = "assert_cmd" version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dc477793bd82ec39799b6f6b3df64938532fdf2ab0d49ef817eac65856a5a1e" dependencies = [ - "escargot 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "predicates 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "predicates-core 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "predicates-tree 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "escargot", + "predicates", + "predicates-core", + "predicates-tree", ] [[package]] name = "atty" version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" dependencies = [ - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", - "termion 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "libc", + "termion", + "winapi 0.3.8", ] [[package]] name = "autocfg" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e49efa51329a5fd37e7c79db4621af617cd4e3e5bc224939808d076077077bf" [[package]] name = "bitflags" version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" [[package]] name = "cfg-if" version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b486ce3ccf7ffd79fdeb678eac06a9e6c09fc88d33836340becb8fffe87c5e33" [[package]] name = "clap" version = "2.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" dependencies = [ - "ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "ansi_term", + "atty", + "bitflags", + "strsim", + "textwrap", + "unicode-width", + "vec_map", ] [[package]] name = "clicolors-control" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73abfd4c73d003a674ce5d2933fca6ce6c42480ea84a5ffe0a2dc39ed56300f9" dependencies = [ - "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "atty", + "lazy_static", + "libc", + "winapi 0.3.8", ] [[package]] name = "cloudabi" version = "0.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" dependencies = [ - "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags", ] [[package]] name = "console" version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ca57c2c14b8a2bf3105bc9d15574aad80babf6a9c44b1058034cdf8bd169628" dependencies = [ - "atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "clicolors-control 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "encode_unicode 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "termios 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "atty", + "clicolors-control", + "encode_unicode", + "lazy_static", + "libc", + "parking_lot", + "regex", + "termios", + "unicode-width", + "winapi 0.3.8", ] [[package]] name = "console" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b147390a412132d75d10dd3b7b175a69cf5fd95032f7503c7091b8831ba10242" dependencies = [ - "clicolors-control 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "encode_unicode 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "termios 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "clicolors-control", + "encode_unicode", + "lazy_static", + "libc", + "regex", + "termios", + "unicode-width", + "winapi 0.3.8", ] [[package]] name = "difference" version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198" [[package]] name = "encode_unicode" version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90b2c9496c001e8cb61827acdefad780795c42264c137744cae6f7d9e3450abd" [[package]] name = "escargot" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ceb9adbf9874d5d028b5e4c5739d22b71988252b25c9c98fe7cf9738bee84597" dependencies = [ - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static", + "log", + "serde", + "serde_json", ] [[package]] name = "filetime" version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f8c63033fcba1f51ef744505b3cad42510432b904c062afa67ad7ece008429d" dependencies = [ - "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if", + "libc", + "redox_syscall", ] [[package]] name = "float-cmp" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "134a8fa843d80a51a5b77d36d42bc2def9edcb0262c914861d08129fd1926600" dependencies = [ - "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits", ] [[package]] name = "fsevent" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ab7d1bd1bd33cc98b0889831b72da23c0aa4df9cec7e0702f46ecea04b35db6" dependencies = [ - "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "fsevent-sys 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags", + "fsevent-sys", ] [[package]] name = "fsevent-sys" version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f41b048a94555da0f42f1d632e2e19510084fb8e303b0daa2816e733fb3644a0" dependencies = [ - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "libc", ] [[package]] name = "fuchsia-cprng" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" [[package]] name = "fuchsia-zircon" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" dependencies = [ - "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags", + "fuchsia-zircon-sys", ] [[package]] name = "fuchsia-zircon-sys" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" [[package]] name = "glob" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" [[package]] name = "indicatif" version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40ecd1e2ee08e6c255ce890f5a99d17000850e664e7acf119fb03b25b0575bfe" dependencies = [ - "console 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "number_prefix 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "console 0.8.0", + "lazy_static", + "number_prefix", + "parking_lot", + "regex", ] [[package]] name = "inotify" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24e40d6fd5d64e2082e0c796495c8ef5ad667a96d03e5aaa0becfd9d47bcbfb8" dependencies = [ - "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "inotify-sys 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags", + "inotify-sys", + "libc", ] [[package]] name = "inotify-sys" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e74a1aa87c59aeff6ef2cc2fa62d41bc43f54952f55652656b18a02fd5e356c0" dependencies = [ - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "libc", ] [[package]] name = "iovec" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08" dependencies = [ - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "libc", + "winapi 0.2.8", ] [[package]] name = "itoa" version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" [[package]] name = "kernel32-sys" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" dependencies = [ - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.8", + "winapi-build", ] [[package]] name = "lazy_static" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" [[package]] name = "lazycell" version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f" [[package]] name = "libc" version = "0.2.58" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6281b86796ba5e4366000be6e9e18bf35580adf9e63fbe2294aadb587613a319" [[package]] name = "lock_api" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed946d4529956a20f2d63ebe1b69996d5a2137c91913fe3ebbeff957f5bca7ff" dependencies = [ - "scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "scopeguard", ] [[package]] name = "log" version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6" dependencies = [ - "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if", ] [[package]] name = "memchr" version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2efc7bc57c883d4a4d6e3246905283d8dae951bb3bd32f49d6ef297f546e1c39" [[package]] name = "mio" version = "0.6.19" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83f51996a3ed004ef184e16818edc51fadffe8e7ca68be67f9dee67d84d0ff23" dependencies = [ - "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", - "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "fuchsia-zircon", + "fuchsia-zircon-sys", + "iovec", + "kernel32-sys", + "libc", + "log", + "miow", + "net2", + "slab", + "winapi 0.2.8", ] [[package]] name = "mio-extras" version = "2.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46e73a04c2fa6250b8d802134d56d554a9ec2922bf977777c805ea5def61ce40" dependencies = [ - "lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", - "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "lazycell", + "log", + "mio", + "slab", ] [[package]] name = "miow" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" dependencies = [ - "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "kernel32-sys", + "net2", + "winapi 0.2.8", + "ws2_32-sys", ] [[package]] name = "net2" version = "0.2.33" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88" dependencies = [ - "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if", + "libc", + "winapi 0.3.8", ] [[package]] name = "normalize-line-endings" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e0a1a39eab95caf4f5556da9289b9e68f0aafac901b2ce80daaf020d3b733a8" [[package]] name = "notify" version = "4.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80ae4a7688d1fab81c5bf19c64fc8db920be8d519ce6336ed4e7efe024724dbd" dependencies = [ - "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "filetime 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", - "fsevent 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "fsevent-sys 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "inotify 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", - "mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)", - "mio-extras 2.0.5 (registry+https://github.com/rust-lang/crates.io-index)", - "walkdir 2.2.7 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags", + "filetime", + "fsevent", + "fsevent-sys", + "inotify", + "libc", + "mio", + "mio-extras", + "walkdir", + "winapi 0.3.8", ] [[package]] name = "num-traits" version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ba9a427cfca2be13aa6f6403b0b7e7368fe982bfa16fccc450ce74c46cd9b32" dependencies = [ - "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg", ] [[package]] name = "number_prefix" version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbf9993e59c894e3c08aa1c2712914e9e6bf1fcbfc6bef283e2183df345a4fee" dependencies = [ - "num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits", ] [[package]] name = "numtoa" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8f8bdf33df195859076e54ab11ee78a1b208382d3a26ec40d142ffc1ecc49ef" [[package]] name = "parking_lot" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa7767817701cce701d5585b9c4db3cdd02086398322c1d7e8bf5094a96a2ce7" dependencies = [ - "lock_api 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "parking_lot_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "lock_api", + "parking_lot_core", + "rustc_version", ] [[package]] name = "parking_lot_core" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb88cb1cb3790baa6776844f968fea3be44956cf184fa1be5a03341f5491278c" dependencies = [ - "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if", + "cloudabi", + "libc", + "rand", + "redox_syscall", + "rustc_version", + "smallvec", + "winapi 0.3.8", ] [[package]] name = "predicates" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53e09015b0d3f5a0ec2d4428f7559bb7b3fff341b4e159fedd1d57fac8b939ff" dependencies = [ - "difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "float-cmp 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "normalize-line-endings 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "predicates-core 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "difference", + "float-cmp", + "normalize-line-endings", + "predicates-core", + "regex", ] [[package]] name = "predicates-core" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06075c3a3e92559ff8929e7a280684489ea27fe44805174c3ebd9328dcb37178" [[package]] name = "predicates-tree" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e63c4859013b38a76eca2414c64911fba30def9e3202ac461a2d22831220124" dependencies = [ - "predicates-core 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "treeline 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "predicates-core", + "treeline", ] [[package]] name = "proc-macro2" version = "0.4.30" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" dependencies = [ - "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-xid", ] [[package]] name = "quote" version = "0.6.12" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "faf4799c5d274f3868a4aae320a0a182cbd2baee377b378f080e16a23e9d80db" dependencies = [ - "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2", ] [[package]] name = "rand" version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" dependencies = [ - "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_jitter 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg", + "libc", + "rand_chacha", + "rand_core 0.4.0", + "rand_hc", + "rand_isaac", + "rand_jitter", + "rand_os", + "rand_pcg", + "rand_xorshift", + "winapi 0.3.8", ] [[package]] name = "rand_chacha" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" dependencies = [ - "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg", + "rand_core 0.3.1", ] [[package]] name = "rand_core" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" dependencies = [ - "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.4.0", ] [[package]] name = "rand_core" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0e7a549d590831370895ab7ba4ea0c1b6b011d106b5ff2da6eee112615e6dc0" [[package]] name = "rand_hc" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" dependencies = [ - "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.3.1", ] [[package]] name = "rand_isaac" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" dependencies = [ - "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.3.1", ] [[package]] name = "rand_jitter" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" dependencies = [ - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "libc", + "rand_core 0.4.0", + "winapi 0.3.8", ] [[package]] name = "rand_os" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" dependencies = [ - "cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)", - "fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "cloudabi", + "fuchsia-cprng", + "libc", + "rand_core 0.4.0", + "rdrand", + "winapi 0.3.8", ] [[package]] name = "rand_pcg" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" dependencies = [ - "autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg", + "rand_core 0.4.0", ] [[package]] name = "rand_xorshift" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" dependencies = [ - "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.3.1", ] [[package]] name = "rdrand" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" dependencies = [ - "rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core 0.3.1", ] [[package]] name = "redox_syscall" version = "0.1.54" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12229c14a0f65c4f1cb046a3b52047cdd9da1f4b30f8a39c5063c8bae515e252" [[package]] name = "redox_termios" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" dependencies = [ - "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall", ] [[package]] name = "regex" version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f0a0bcab2fd7d1d7c54fa9eae6f43eddeb9ce2e7352f8518a814a4f65d60c58" dependencies = [ - "aho-corasick 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex-syntax 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", - "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", - "utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "aho-corasick", + "memchr", + "regex-syntax", + "thread_local", + "utf8-ranges", ] [[package]] name = "regex-syntax" version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcfd8681eebe297b81d98498869d4aae052137651ad7b96822f09ceb690d0a96" dependencies = [ - "ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "ucd-util", ] [[package]] name = "rustc_version" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" dependencies = [ - "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "semver", ] [[package]] name = "rustlings" -version = "4.2.0" +version = "4.3.0" dependencies = [ - "assert_cmd 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)", - "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", - "console 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)", - "glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "indicatif 0.10.3 (registry+https://github.com/rust-lang/crates.io-index)", - "notify 4.0.15 (registry+https://github.com/rust-lang/crates.io-index)", - "predicates 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", - "toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)", + "assert_cmd", + "clap", + "console 0.7.7", + "glob", + "indicatif", + "notify", + "predicates", + "regex", + "serde", + "toml", ] [[package]] name = "ryu" version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b96a9549dc8d48f2c283938303c4b5a77aa29bfbc5b54b084fb1630408899a8f" [[package]] name = "same-file" version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f20c4be53a8a1ff4c1f1b2bd14570d2f634628709752f0702ecdd2b3f9a5267" dependencies = [ - "winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-util", ] [[package]] name = "scopeguard" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b42e15e59b18a828bbf5c58ea01debb36b9b096346de35d941dcb89009f24a0d" [[package]] name = "semver" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" dependencies = [ - "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "semver-parser", ] [[package]] name = "semver-parser" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32746bf0f26eab52f06af0d0aa1984f641341d06d8d673c693871da2d188c9be" dependencies = [ - "serde_derive 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive", ] [[package]] name = "serde_derive" version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46a3223d0c9ba936b61c0d2e3e559e3217dbfb8d65d06d26e8b3c25de38bae3e" dependencies = [ - "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2", + "quote", + "syn", ] [[package]] name = "serde_json" version = "1.0.39" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a23aa71d4a4d43fdbfaac00eff68ba8a06a51759a89ac3304323e800c4dd40d" dependencies = [ - "itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "ryu 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", + "itoa", + "ryu", + "serde", ] [[package]] name = "slab" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" [[package]] name = "smallvec" version = "0.6.9" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4488ae950c49d403731982257768f48fada354a5203fe81f9bb6f43ca9002be" [[package]] name = "strsim" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" [[package]] name = "syn" version = "0.15.34" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1393e4a97a19c01e900df2aec855a29f71cf02c402e2f443b8d2747c25c5dbe" dependencies = [ - "proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)", - "quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2", + "quote", + "unicode-xid", ] [[package]] name = "termion" version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dde0593aeb8d47accea5392b39350015b5eccb12c0d98044d856983d89548dea" dependencies = [ - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", - "numtoa 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libc", + "numtoa", + "redox_syscall", + "redox_termios", ] [[package]] name = "termios" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b620c5ea021d75a735c943269bb07d30c9b77d6ac6b236bc8b5c496ef05625" dependencies = [ - "libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)", + "libc", ] [[package]] name = "textwrap" version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" dependencies = [ - "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-width", ] [[package]] name = "thread_local" version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" dependencies = [ - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static", ] [[package]] name = "toml" version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "758664fc71a3a69038656bee8b6be6477d2a6c315a6b81f7081f591bffa4111f" dependencies = [ - "serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)", + "serde", ] [[package]] name = "treeline" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7f741b240f1a48843f9b8e0444fb55fb2a4ff67293b50a9179dfd5ea67f8d41" [[package]] name = "ucd-util" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "535c204ee4d8434478593480b8f86ab45ec9aae0e83c568ca81abf0fd0e88f86" [[package]] name = "unicode-width" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "882386231c45df4700b275c7ff55b6f3698780a650026380e72dabe76fa46526" [[package]] name = "unicode-xid" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" [[package]] name = "utf8-ranges" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "796f7e48bef87609f7ade7e06495a87d5cd06c7866e6a5cbfceffc558a243737" [[package]] name = "vec_map" version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" [[package]] name = "walkdir" version = "2.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d9d7ed3431229a144296213105a390676cc49c9b6a72bd19f3176c98e129fa1" dependencies = [ - "same-file 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "same-file", + "winapi 0.3.8", + "winapi-util", ] [[package]] name = "winapi" version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" [[package]] name = "winapi" version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" dependencies = [ - "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", ] [[package]] name = "winapi-build" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" [[package]] name = "winapi-i686-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7168bab6e1daee33b4557efd0e95d5ca70a03706d39fa5f3fe7a236f584b03c9" dependencies = [ - "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8", ] [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "ws2_32-sys" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" dependencies = [ - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.8", + "winapi-build", ] - -[metadata] -"checksum aho-corasick 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e6f484ae0c99fec2e858eb6134949117399f222608d84cadb3f58c1f97c2364c" -"checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" -"checksum assert_cmd 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2dc477793bd82ec39799b6f6b3df64938532fdf2ab0d49ef817eac65856a5a1e" -"checksum atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" -"checksum autocfg 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "0e49efa51329a5fd37e7c79db4621af617cd4e3e5bc224939808d076077077bf" -"checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" -"checksum cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b486ce3ccf7ffd79fdeb678eac06a9e6c09fc88d33836340becb8fffe87c5e33" -"checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" -"checksum clicolors-control 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "73abfd4c73d003a674ce5d2933fca6ce6c42480ea84a5ffe0a2dc39ed56300f9" -"checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" -"checksum console 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)" = "8ca57c2c14b8a2bf3105bc9d15574aad80babf6a9c44b1058034cdf8bd169628" -"checksum console 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b147390a412132d75d10dd3b7b175a69cf5fd95032f7503c7091b8831ba10242" -"checksum difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198" -"checksum encode_unicode 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "90b2c9496c001e8cb61827acdefad780795c42264c137744cae6f7d9e3450abd" -"checksum escargot 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ceb9adbf9874d5d028b5e4c5739d22b71988252b25c9c98fe7cf9738bee84597" -"checksum filetime 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "2f8c63033fcba1f51ef744505b3cad42510432b904c062afa67ad7ece008429d" -"checksum float-cmp 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "134a8fa843d80a51a5b77d36d42bc2def9edcb0262c914861d08129fd1926600" -"checksum fsevent 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5ab7d1bd1bd33cc98b0889831b72da23c0aa4df9cec7e0702f46ecea04b35db6" -"checksum fsevent-sys 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f41b048a94555da0f42f1d632e2e19510084fb8e303b0daa2816e733fb3644a0" -"checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" -"checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" -"checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" -"checksum glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" -"checksum indicatif 0.10.3 (registry+https://github.com/rust-lang/crates.io-index)" = "40ecd1e2ee08e6c255ce890f5a99d17000850e664e7acf119fb03b25b0575bfe" -"checksum inotify 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "24e40d6fd5d64e2082e0c796495c8ef5ad667a96d03e5aaa0becfd9d47bcbfb8" -"checksum inotify-sys 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e74a1aa87c59aeff6ef2cc2fa62d41bc43f54952f55652656b18a02fd5e356c0" -"checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08" -"checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" -"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" -"checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" -"checksum lazycell 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f" -"checksum libc 0.2.58 (registry+https://github.com/rust-lang/crates.io-index)" = "6281b86796ba5e4366000be6e9e18bf35580adf9e63fbe2294aadb587613a319" -"checksum lock_api 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ed946d4529956a20f2d63ebe1b69996d5a2137c91913fe3ebbeff957f5bca7ff" -"checksum log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6" -"checksum memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2efc7bc57c883d4a4d6e3246905283d8dae951bb3bd32f49d6ef297f546e1c39" -"checksum mio 0.6.19 (registry+https://github.com/rust-lang/crates.io-index)" = "83f51996a3ed004ef184e16818edc51fadffe8e7ca68be67f9dee67d84d0ff23" -"checksum mio-extras 2.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "46e73a04c2fa6250b8d802134d56d554a9ec2922bf977777c805ea5def61ce40" -"checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" -"checksum net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88" -"checksum normalize-line-endings 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2e0a1a39eab95caf4f5556da9289b9e68f0aafac901b2ce80daaf020d3b733a8" -"checksum notify 4.0.15 (registry+https://github.com/rust-lang/crates.io-index)" = "80ae4a7688d1fab81c5bf19c64fc8db920be8d519ce6336ed4e7efe024724dbd" -"checksum num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "6ba9a427cfca2be13aa6f6403b0b7e7368fe982bfa16fccc450ce74c46cd9b32" -"checksum number_prefix 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "dbf9993e59c894e3c08aa1c2712914e9e6bf1fcbfc6bef283e2183df345a4fee" -"checksum numtoa 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b8f8bdf33df195859076e54ab11ee78a1b208382d3a26ec40d142ffc1ecc49ef" -"checksum parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fa7767817701cce701d5585b9c4db3cdd02086398322c1d7e8bf5094a96a2ce7" -"checksum parking_lot_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cb88cb1cb3790baa6776844f968fea3be44956cf184fa1be5a03341f5491278c" -"checksum predicates 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "53e09015b0d3f5a0ec2d4428f7559bb7b3fff341b4e159fedd1d57fac8b939ff" -"checksum predicates-core 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "06075c3a3e92559ff8929e7a280684489ea27fe44805174c3ebd9328dcb37178" -"checksum predicates-tree 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8e63c4859013b38a76eca2414c64911fba30def9e3202ac461a2d22831220124" -"checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" -"checksum quote 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)" = "faf4799c5d274f3868a4aae320a0a182cbd2baee377b378f080e16a23e9d80db" -"checksum rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" -"checksum rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" -"checksum rand_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" -"checksum rand_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d0e7a549d590831370895ab7ba4ea0c1b6b011d106b5ff2da6eee112615e6dc0" -"checksum rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" -"checksum rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" -"checksum rand_jitter 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" -"checksum rand_os 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" -"checksum rand_pcg 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" -"checksum rand_xorshift 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" -"checksum rdrand 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" -"checksum redox_syscall 0.1.54 (registry+https://github.com/rust-lang/crates.io-index)" = "12229c14a0f65c4f1cb046a3b52047cdd9da1f4b30f8a39c5063c8bae515e252" -"checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" -"checksum regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "8f0a0bcab2fd7d1d7c54fa9eae6f43eddeb9ce2e7352f8518a814a4f65d60c58" -"checksum regex-syntax 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)" = "dcfd8681eebe297b81d98498869d4aae052137651ad7b96822f09ceb690d0a96" -"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -"checksum ryu 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "b96a9549dc8d48f2c283938303c4b5a77aa29bfbc5b54b084fb1630408899a8f" -"checksum same-file 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8f20c4be53a8a1ff4c1f1b2bd14570d2f634628709752f0702ecdd2b3f9a5267" -"checksum scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b42e15e59b18a828bbf5c58ea01debb36b9b096346de35d941dcb89009f24a0d" -"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum serde 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)" = "32746bf0f26eab52f06af0d0aa1984f641341d06d8d673c693871da2d188c9be" -"checksum serde_derive 1.0.92 (registry+https://github.com/rust-lang/crates.io-index)" = "46a3223d0c9ba936b61c0d2e3e559e3217dbfb8d65d06d26e8b3c25de38bae3e" -"checksum serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)" = "5a23aa71d4a4d43fdbfaac00eff68ba8a06a51759a89ac3304323e800c4dd40d" -"checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" -"checksum smallvec 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)" = "c4488ae950c49d403731982257768f48fada354a5203fe81f9bb6f43ca9002be" -"checksum strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" -"checksum syn 0.15.34 (registry+https://github.com/rust-lang/crates.io-index)" = "a1393e4a97a19c01e900df2aec855a29f71cf02c402e2f443b8d2747c25c5dbe" -"checksum termion 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dde0593aeb8d47accea5392b39350015b5eccb12c0d98044d856983d89548dea" -"checksum termios 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "72b620c5ea021d75a735c943269bb07d30c9b77d6ac6b236bc8b5c496ef05625" -"checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" -"checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" -"checksum toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "758664fc71a3a69038656bee8b6be6477d2a6c315a6b81f7081f591bffa4111f" -"checksum treeline 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a7f741b240f1a48843f9b8e0444fb55fb2a4ff67293b50a9179dfd5ea67f8d41" -"checksum ucd-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "535c204ee4d8434478593480b8f86ab45ec9aae0e83c568ca81abf0fd0e88f86" -"checksum unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "882386231c45df4700b275c7ff55b6f3698780a650026380e72dabe76fa46526" -"checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" -"checksum utf8-ranges 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "796f7e48bef87609f7ade7e06495a87d5cd06c7866e6a5cbfceffc558a243737" -"checksum vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" -"checksum walkdir 2.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "9d9d7ed3431229a144296213105a390676cc49c9b6a72bd19f3176c98e129fa1" -"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" -"checksum winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" -"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" -"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" -"checksum winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7168bab6e1daee33b4557efd0e95d5ca70a03706d39fa5f3fe7a236f584b03c9" -"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -"checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" diff --git a/Cargo.toml b/Cargo.toml index ebce25eb..a0564c37 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rustlings" -version = "4.2.0" +version = "4.3.0" authors = ["Marisa ", "Carol (Nichols || Goulding) "] edition = "2018" diff --git a/README.md b/README.md index 9512ac5c..a5371043 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ Basically: Clone the repository, checkout to the latest tag, run `cargo install` ```bash git clone https://github.com/rust-lang/rustlings cd rustlings -git checkout tags/4.2.0 # or whatever the latest version is (find out at https://github.com/rust-lang/rustlings/releases/latest) +git checkout tags/4.3.0 # or whatever the latest version is (find out at https://github.com/rust-lang/rustlings/releases/latest) cargo install --force --path . ``` diff --git a/src/main.rs b/src/main.rs index 35f8df4d..bf35e4fb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -25,7 +25,7 @@ mod verify; fn main() { let matches = App::new("rustlings") .version(crate_version!()) - .author("Olivia Hugger, Carol Nichols") + .author("Marisa, Carol Nichols") .about("Rustlings is a collection of small exercises to get you used to writing and reading Rust code") .arg( Arg::with_name("nocapture") From 644c49f1e04cbb24e95872b3a52b07d692ae3bc8 Mon Sep 17 00:00:00 2001 From: xehpuk Date: Wed, 30 Dec 2020 22:56:04 +0100 Subject: [PATCH 101/282] fix: typo in default out text --- default_out.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/default_out.txt b/default_out.txt index 44b7734c..b90d1e3a 100644 --- a/default_out.txt +++ b/default_out.txt @@ -6,7 +6,7 @@ started, here's a couple of notes about how Rustlings operates: 1. The central concept behind Rustlings is that you solve exercises. These exercises usually have some sort of syntax error in them, which will cause - them to fail compliation or testing. Sometimes there's a logic error instead + them to fail compilation or testing. Sometimes there's a logic error instead of a syntax error. No matter what error, it's your job to find it and fix it! You'll know when you fixed it because then, the exercise will compile and Rustlings will be able to move on to the next exercise. From ff6cba7205fc9b1a5cbb10dcf4f7887b153a4930 Mon Sep 17 00:00:00 2001 From: RoelofWobben <75732370+RoelofWobben@users.noreply.github.com> Date: Sun, 27 Dec 2020 10:49:55 +0100 Subject: [PATCH 102/282] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index a5371043..16f8c3d8 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,8 @@ Start-BitsTransfer -Source https://git.io/rustlings-win -Destination $env:TMP/in To install Rustlings. Same as on MacOS/Linux, you will have access to the `rustlings` command after it. +When you get a permission denied message then you have to exclude the directory where you placed the rustlings in your virus-scanner + ## Browser: [Run on Repl.it](https://repl.it/github/rust-lang/rustlings) From e9b42bbc2a20df848950375a5baafc0620017a9c Mon Sep 17 00:00:00 2001 From: Will Hayworth Date: Sun, 3 Jan 2021 03:42:39 -0800 Subject: [PATCH 103/282] docs: mention flatten in the options2 hint --- info.toml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/info.toml b/info.toml index ee4ab2f6..15cd3f3f 100644 --- a/info.toml +++ b/info.toml @@ -583,8 +583,7 @@ https://doc.rust-lang.org/rust-by-example/flow_control/while_let.html Remember that Options can be stacked in if let and while let. For example: Some(Some(variable)) = variable2 - - +Also see Option::flatten """ [[exercises]] From c355ac6593e94e09459dea93a11371f132913123 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Mon, 4 Jan 2021 13:12:10 +0000 Subject: [PATCH 104/282] docs: update README.md [skip ci] --- README.md | 146 +++++++++++++++++++++++++++--------------------------- 1 file changed, 74 insertions(+), 72 deletions(-) diff --git a/README.md b/README.md index 16f8c3d8..b67793d4 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ![crab pet](https://i.imgur.com/LbZJgmm.gif) -[![All Contributors](https://img.shields.io/badge/all_contributors-70-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-71-orange.svg?style=flat-square)](#contributors-) # rustlings πŸ¦€β€οΈ @@ -169,97 +169,99 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + - - - - - - + + + + + + +

Carol (Nichols || Goulding)

πŸ’» πŸ–‹

QuietMisdreavus

πŸ’» πŸ–‹

Robert M Lugg

πŸ–‹

Hynek Schlawack

πŸ’»

Katharina Fey

πŸ’»

lukabavdaz

πŸ’» πŸ–‹

Erik Vesteraas

πŸ’»

delet0r

πŸ’»

Carol (Nichols || Goulding)

πŸ’» πŸ–‹

QuietMisdreavus

πŸ’» πŸ–‹

Robert M Lugg

πŸ–‹

Hynek Schlawack

πŸ’»

Katharina Fey

πŸ’»

lukabavdaz

πŸ’» πŸ–‹

Erik Vesteraas

πŸ’»

delet0r

πŸ’»

Shaun Bennett

πŸ’»

Andrew Bagshaw

πŸ’»

Kyle Isom

πŸ’»

Colin Pitrat

πŸ’»

Zac Anger

πŸ’»

Matthias Geier

πŸ’»

Chris Pearce

πŸ’»

Yvan Sraka

πŸ’»

Shaun Bennett

πŸ’»

Andrew Bagshaw

πŸ’»

Kyle Isom

πŸ’»

Colin Pitrat

πŸ’»

Zac Anger

πŸ’»

Matthias Geier

πŸ’»

Chris Pearce

πŸ’»

Yvan Sraka

πŸ’»

Denys Smirnov

πŸ’»

eddyp

πŸ’»

Brian Kung

πŸ’» πŸ–‹

Russell

πŸ’»

Dan Wilhelm

πŸ“–

Jesse

πŸ’» πŸ–‹

Fredrik JambrΓ©n

πŸ’»

Pete McFarlane

πŸ–‹

Denys Smirnov

πŸ’»

eddyp

πŸ’»

Brian Kung

πŸ’» πŸ–‹

Russell

πŸ’»

Dan Wilhelm

πŸ“–

Jesse

πŸ’» πŸ–‹

Fredrik JambrΓ©n

πŸ’»

Pete McFarlane

πŸ–‹

nkanderson

πŸ’» πŸ–‹

Ajax M

πŸ“–

Dylan Nugent

πŸ–‹

vyaslav

πŸ’» πŸ–‹

George

πŸ’»

Thomas Holloway

πŸ’» πŸ–‹

Jubilee

πŸ’»

WofWca

πŸ’»

nkanderson

πŸ’» πŸ–‹

Ajax M

πŸ“–

Dylan Nugent

πŸ–‹

vyaslav

πŸ’» πŸ–‹

George

πŸ’»

Thomas Holloway

πŸ’» πŸ–‹

Jubilee

πŸ’»

WofWca

πŸ’»

Roberto Vidal

πŸ’» πŸ“– πŸ€” 🚧

Jens

πŸ“–

Rahat Ahmed

πŸ“–

Abdou Seck

πŸ’» πŸ–‹ πŸ‘€

Katie

πŸ’»

Socrates

πŸ“–

gnodarse

πŸ–‹

Harrison Metzger

πŸ’»

Roberto Vidal

πŸ’» πŸ“– πŸ€” 🚧

Jens

πŸ“–

Rahat Ahmed

πŸ“–

Abdou Seck

πŸ’» πŸ–‹ πŸ‘€

Katie

πŸ’»

Socrates

πŸ“–

gnodarse

πŸ–‹

Harrison Metzger

πŸ’»

Torben Jonas

πŸ’» πŸ–‹

Paul Bissex

πŸ“–

Steven Mann

πŸ’» πŸ–‹

Mario Reder

πŸ’» πŸ–‹

skim

πŸ’»

Sanjay K

πŸ’» πŸ–‹

Rohan Jain

πŸ’»

Said Aspen

πŸ’» πŸ–‹

Torben Jonas

πŸ’» πŸ–‹

Paul Bissex

πŸ“–

Steven Mann

πŸ’» πŸ–‹

Mario Reder

πŸ’» πŸ–‹

skim

πŸ’»

Sanjay K

πŸ’» πŸ–‹

Rohan Jain

πŸ’»

Said Aspen

πŸ’» πŸ–‹

Ufuk Celebi

πŸ’»

lebedevsergey

πŸ“–

Aleksei Trifonov

πŸ–‹

Darren Meehan

πŸ–‹

Jihchi Lee

πŸ–‹

Christofer Bertonha

πŸ–‹

Vivek Bharath Akupatni

πŸ’» ⚠️

DΓ­dac SementΓ© FernΓ‘ndez

πŸ’» πŸ–‹

Ufuk Celebi

πŸ’»

lebedevsergey

πŸ“–

Aleksei Trifonov

πŸ–‹

Darren Meehan

πŸ–‹

Jihchi Lee

πŸ–‹

Christofer Bertonha

πŸ–‹

Vivek Bharath Akupatni

πŸ’» ⚠️

DΓ­dac SementΓ© FernΓ‘ndez

πŸ’» πŸ–‹

Rob Story

πŸ’»

Siobhan Jacobson

πŸ’»

Evan Carroll

πŸ–‹

Jawaad Mahmood

πŸ–‹

Gaurang Tandon

πŸ–‹

Stefan Kupresak

πŸ–‹

Greg Leonard

πŸ–‹

Ryan McQuen

πŸ’»

Rob Story

πŸ’»

Siobhan Jacobson

πŸ’»

Evan Carroll

πŸ–‹

Jawaad Mahmood

πŸ–‹

Gaurang Tandon

πŸ–‹

Stefan Kupresak

πŸ–‹

Greg Leonard

πŸ–‹

Ryan McQuen

πŸ’»

Annika

πŸ‘€

Axel Viala

πŸ’»

Mohammed Sazid Al Rashid

πŸ–‹ πŸ’»

Caleb Webber

🚧

Peter N

🚧

seancad

🚧

Annika

πŸ‘€

Axel Viala

πŸ’»

Mohammed Sazid Al Rashid

πŸ–‹ πŸ’»

Caleb Webber

🚧

Peter N

🚧

seancad

🚧

Will Hayworth

πŸ–‹
- + + This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome! From 6df08b411bc09fd10d510be74c80e9cc6164e145 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Mon, 4 Jan 2021 13:12:11 +0000 Subject: [PATCH 105/282] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 1549aa45..d2b0fae1 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -655,6 +655,15 @@ "contributions": [ "maintenance" ] + }, + { + "login": "wsh", + "name": "Will Hayworth", + "avatar_url": "https://avatars3.githubusercontent.com/u/181174?v=4", + "profile": "http://willhayworth.com", + "contributions": [ + "content" + ] } ], "contributorsPerLine": 8, From 10965920fbdf8a1efc85bed869e55a1787006404 Mon Sep 17 00:00:00 2001 From: Marius Ungureanu Date: Wed, 6 Jan 2021 11:12:33 +0200 Subject: [PATCH 106/282] fix(move_semantics4): Small readbility improvement (#617) * Small readbility improvement move_semantics4 doc * Remove `an` as it refers to the argument --- exercises/move_semantics/move_semantics4.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/move_semantics/move_semantics4.rs b/exercises/move_semantics/move_semantics4.rs index a1c4a413..6308c296 100644 --- a/exercises/move_semantics/move_semantics4.rs +++ b/exercises/move_semantics/move_semantics4.rs @@ -18,7 +18,7 @@ fn main() { println!("{} has length {} content `{:?}`", "vec1", vec1.len(), vec1); } -// `fill_vec()` no longer take `vec: Vec` as argument +// `fill_vec()` no longer takes `vec: Vec` as argument fn fill_vec() -> Vec { let mut vec = vec; From 7857b0a689b0847f48d8c14cbd1865e3b812d5ca Mon Sep 17 00:00:00 2001 From: Christian Zeller Date: Wed, 6 Jan 2021 13:47:20 +0100 Subject: [PATCH 107/282] fix(threads1): line number correction --- exercises/threads/threads1.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/threads/threads1.rs b/exercises/threads/threads1.rs index b475b4a1..f31b317e 100644 --- a/exercises/threads/threads1.rs +++ b/exercises/threads/threads1.rs @@ -1,6 +1,6 @@ // threads1.rs // Make this compile! Execute `rustlings hint threads1` for hints :) -// The idea is the thread spawned on line 21 is completing jobs while the main thread is +// The idea is the thread spawned on line 22 is completing jobs while the main thread is // monitoring progress until 10 jobs are completed. Because of the difference between the // spawned threads' sleep time, and the waiting threads sleep time, when you see 6 lines // of "waiting..." and the program ends without timing out when running, From 621816fb561a9501aa15e8c3674ccdff3b2b24fe Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Wed, 6 Jan 2021 15:54:33 +0000 Subject: [PATCH 108/282] docs: update README.md [skip ci] --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b67793d4..f489f93d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ![crab pet](https://i.imgur.com/LbZJgmm.gif) -[![All Contributors](https://img.shields.io/badge/all_contributors-71-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-72-orange.svg?style=flat-square)](#contributors-) # rustlings πŸ¦€β€οΈ @@ -256,6 +256,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Peter N

🚧
seancad

🚧
Will Hayworth

πŸ–‹ +
Christian Zeller

πŸ–‹ From c24a78ae94b0e8527ee75908edeea136a7a3dbeb Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Wed, 6 Jan 2021 15:54:34 +0000 Subject: [PATCH 109/282] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index d2b0fae1..46e68ae5 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -664,6 +664,15 @@ "contributions": [ "content" ] + }, + { + "login": "chrizel", + "name": "Christian Zeller", + "avatar_url": "https://avatars3.githubusercontent.com/u/20802?v=4", + "profile": "https://github.com/chrizel", + "contributions": [ + "content" + ] } ], "contributorsPerLine": 8, From fea86c29d6b0b29513e1cfb56b9eab5d4dcd121e Mon Sep 17 00:00:00 2001 From: fmoko Date: Fri, 8 Jan 2021 14:01:04 +0100 Subject: [PATCH 110/282] chore: Remove Readme GIF --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index f489f93d..987bb839 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,3 @@ -![crab pet](https://i.imgur.com/LbZJgmm.gif) [![All Contributors](https://img.shields.io/badge/all_contributors-72-orange.svg?style=flat-square)](#contributors-) From 5a0521e92c80c43d6451fcc520fd68e7f56106f8 Mon Sep 17 00:00:00 2001 From: Sang-Heon Jeon Date: Sat, 9 Jan 2021 00:07:13 +0900 Subject: [PATCH 111/282] feat(from_str) : add test for checking unnecessary trailing value --- exercises/conversions/from_str.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/exercises/conversions/from_str.rs b/exercises/conversions/from_str.rs index af9eee6d..70ed1796 100644 --- a/exercises/conversions/from_str.rs +++ b/exercises/conversions/from_str.rs @@ -82,4 +82,16 @@ mod tests { fn missing_name_and_invalid_age() { ",one".parse::().unwrap(); } + + #[test] + #[should_panic] + fn trailing_comma() { + "John,32,".parse::().unwrap(); + } + + #[test] + #[should_panic] + fn trailing_comma_and_some_string() { + "John,32,man".parse::().unwrap(); + } } From 4f1374a6e7dd76d0f8769adf51495d5d0f9ea8a1 Mon Sep 17 00:00:00 2001 From: Sang-Heon Jeon Date: Sat, 9 Jan 2021 00:08:38 +0900 Subject: [PATCH 112/282] feat(from_into) : add test for checking unnecessary trailing value --- exercises/conversions/from_into.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/exercises/conversions/from_into.rs b/exercises/conversions/from_into.rs index f24cf61b..9d84174d 100644 --- a/exercises/conversions/from_into.rs +++ b/exercises/conversions/from_into.rs @@ -115,4 +115,18 @@ mod tests { assert_eq!(p.name, "John"); assert_eq!(p.age, 30); } + + #[test] + fn test_trailing_comma() { + let p: Person = Person::from("Mike,32,"); + assert_eq!(p.name, "John"); + assert_eq!(p.age, 30); + } + + #[test] + fn test_trailing_comma_and_some_string() { + let p: Person = Person::from("Mike,32,man"); + assert_eq!(p.name, "John"); + assert_eq!(p.age, 30); + } } From 0b9220c1fc5ae32438f64bf2f5bf5f47d33e3f3f Mon Sep 17 00:00:00 2001 From: Abdou Seck Date: Sat, 12 Dec 2020 13:45:37 -0500 Subject: [PATCH 113/282] Add looks_done method to Exercise to expose a resolution state --- src/exercise.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/exercise.rs b/src/exercise.rs index 283b2b90..7afa230a 100644 --- a/src/exercise.rs +++ b/src/exercise.rs @@ -232,6 +232,16 @@ path = "{}.rs""#, State::Pending(context) } + + // Check that the exercise looks to be solved using self.state() + // This is not the best way to check since + // the user can just remove the "I AM NOT DONE" string fromm the file + // without actually having solved anything. + // The only other way to truly check this would to compile and run + // the exercise; which would be both costly and counterintuitive + pub fn looks_done(&self) -> bool { + self.state() == State::Done + } } impl Display for Exercise { From 8bbe4ff1385c5c169c90cd3ff9253f9a91daaf8e Mon Sep 17 00:00:00 2001 From: Abdou Seck Date: Sat, 12 Dec 2020 13:48:25 -0500 Subject: [PATCH 114/282] feat(cli): Improve the list command with options, and then some 1. `rustlings list` should now display more than just the exercise names. Information such as file paths and exercises statuses should be displayed. The `--paths` option limits the displayed fields to only the path names; while the `--names` option limits the displayed fields to only exercise names. You can also control which exercises are displayed, by using the `--filter` option, or the `--solved` or `--unsolved` flags. Some use cases: - Fetching pending exercise files with the keyword "conversion" to pass to my editor: ```sh vim $(rustlings list --filter "conversion" --paths --unsolved) ``` - Fetching exercise names with keyword "conversion" to pass to `rustlings run`: ```sh for exercise in $(rustlings list --filter "conversion" --names) do rustlings run ${exercise} done ``` 2. This should also fix #465, and will likely fix #585, as well. That bug mentioned in those issues has to do with the way the `watch` command handler fetches the pending exercises. Going forward, the least recently updated exercises along with all the other exercises in a pending state are fetched. --- src/main.rs | 132 ++++++++++++++++++++++++++++------ tests/fixture/state/info.toml | 7 ++ tests/integration_tests.rs | 78 ++++++++++++++++++++ 3 files changed, 197 insertions(+), 20 deletions(-) diff --git a/src/main.rs b/src/main.rs index bf35e4fb..75a9cec1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,7 +7,7 @@ use notify::DebouncedEvent; use notify::{RecommendedWatcher, RecursiveMode, Watcher}; use std::ffi::OsStr; use std::fs; -use std::io; +use std::io::{self, prelude::*}; use std::path::Path; use std::process::{Command, Stdio}; use std::sync::mpsc::channel; @@ -58,6 +58,45 @@ fn main() { SubCommand::with_name("list") .alias("l") .about("Lists the exercises available in rustlings") + .arg( + Arg::with_name("paths") + .long("paths") + .short("p") + .conflicts_with("names") + .help("Show only the paths of the exercises") + ) + .arg( + Arg::with_name("names") + .long("names") + .short("n") + .conflicts_with("paths") + .help("Show only the names of the exercises") + ) + .arg( + Arg::with_name("filter") + .long("filter") + .short("f") + .takes_value(true) + .empty_values(false) + .help( + "Provide a string to match the exercise names.\ + \nComma separated patterns are acceptable." + ) + ) + .arg( + Arg::with_name("unsolved") + .long("unsolved") + .short("u") + .conflicts_with("solved") + .help("Display only exercises not yet solved") + ) + .arg( + Arg::with_name("solved") + .long("solved") + .short("s") + .conflicts_with("unsolved") + .help("Display only exercises that have been solved") + ) ) .get_matches(); @@ -93,9 +132,51 @@ fn main() { let exercises = toml::from_str::(toml_str).unwrap().exercises; let verbose = matches.is_present("nocapture"); - if matches.subcommand_matches("list").is_some() { - exercises.iter().for_each(|e| println!("{}", e.name)); + // Handle the list command + if let Some(list_m) = matches.subcommand_matches("list") { + if ["paths", "names"].iter().all(|k| !list_m.is_present(k)) { + println!("{:<17}\t{:<46}\t{:<7}", "Name", "Path", "Status"); + } + let filters = list_m.value_of("filter").unwrap_or_default().to_lowercase(); + exercises.iter().for_each(|e| { + let fname = format!("{}", e.path.display()); + let filter_cond = filters + .split(',') + .filter(|f| f.trim().len() > 0) + .any(|f| e.name.contains(&f) || fname.contains(&f)); + let status = if e.looks_done() { "Done" } else { "Pending" }; + let solve_cond = { + (e.looks_done() && list_m.is_present("solved")) + || (!e.looks_done() && list_m.is_present("unsolved")) + || (!list_m.is_present("solved") && !list_m.is_present("unsolved")) + }; + if solve_cond && (filter_cond || !list_m.is_present("filter")) { + let line = if list_m.is_present("paths") { + format!("{}\n", fname) + } else if list_m.is_present("names") { + format!("{}\n", e.name) + } else { + format!("{:<17}\t{:<46}\t{:<7}\n", e.name, fname, status) + }; + // Somehow using println! leads to the binary panicking + // when its output is piped. + // So, we're handling a Broken Pipe error and exiting with 0 anyway + let stdout = std::io::stdout(); + { + let mut handle = stdout.lock(); + handle.write_all(line.as_bytes()).unwrap_or_else(|e| { + match e.kind() { + std::io::ErrorKind::BrokenPipe => std::process::exit(0), + _ => std::process::exit(1), + }; + }); + } + } + }); + std::process::exit(0); } + + // Handle the run command if let Some(ref matches) = matches.subcommand_matches("run") { let name = matches.value_of("name").unwrap(); @@ -123,13 +204,18 @@ fn main() { println!("{}", exercise.hint); } + // Handle the verify command if matches.subcommand_matches("verify").is_some() { verify(&exercises, verbose).unwrap_or_else(|_| std::process::exit(1)); } + // Handle the watch command if matches.subcommand_matches("watch").is_some() { if let Err(e) = watch(&exercises, verbose) { - println!("Error: Could not watch your progess. Error message was {:?}.", e); + println!( + "Error: Could not watch your progess. Error message was {:?}.", + e + ); println!("Most likely you've run out of disk space or your 'inotify limit' has been reached."); std::process::exit(1); } @@ -138,24 +224,24 @@ fn main() { emoji = Emoji("πŸŽ‰", "β˜…") ); println!(); - println!("+----------------------------------------------------+"); - println!("| You made it to the Fe-nish line! |"); - println!("+-------------------------- ------------------------+"); + println!("+----------------------------------------------------+"); + println!("| You made it to the Fe-nish line! |"); + println!("+-------------------------- ------------------------+"); println!(" \\/ "); - println!(" β–’β–’ β–’β–’β–’β–’β–’β–’β–’β–’ β–’β–’β–’β–’β–’β–’β–’β–’ β–’β–’ "); - println!(" β–’β–’β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’β–’β–’ "); - println!(" β–’β–’β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’β–’β–’ "); - println!(" β–‘β–‘β–’β–’β–’β–’β–‘β–‘β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’β–‘β–‘β–’β–’β–’β–’ "); - println!(" β–“β–“β–“β–“β–“β–“β–“β–“ β–“β–“ β–“β–“β–ˆβ–ˆ β–“β–“ β–“β–“β–ˆβ–ˆ β–“β–“ β–“β–“β–“β–“β–“β–“β–“β–“ "); - println!(" β–’β–’β–’β–’ β–’β–’ β–ˆβ–ˆβ–ˆβ–ˆ β–’β–’ β–ˆβ–ˆβ–ˆβ–ˆ β–’β–’β–‘β–‘ β–’β–’β–’β–’ "); - println!(" β–’β–’ β–’β–’β–’β–’β–’β–’ β–’β–’β–’β–’β–’β–’ β–’β–’β–’β–’β–’β–’ β–’β–’ "); - println!(" β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–“β–“β–“β–“β–“β–“β–’β–’β–’β–’β–’β–’β–’β–’β–“β–“β–’β–’β–“β–“β–’β–’β–’β–’β–’β–’β–’β–’ "); + println!(" β–’β–’ β–’β–’β–’β–’β–’β–’β–’β–’ β–’β–’β–’β–’β–’β–’β–’β–’ β–’β–’ "); + println!(" β–’β–’β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’β–’β–’ "); + println!(" β–’β–’β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’β–’β–’ "); + println!(" β–‘β–‘β–’β–’β–’β–’β–‘β–‘β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’β–‘β–‘β–’β–’β–’β–’ "); + println!(" β–“β–“β–“β–“β–“β–“β–“β–“ β–“β–“ β–“β–“β–ˆβ–ˆ β–“β–“ β–“β–“β–ˆβ–ˆ β–“β–“ β–“β–“β–“β–“β–“β–“β–“β–“ "); + println!(" β–’β–’β–’β–’ β–’β–’ β–ˆβ–ˆβ–ˆβ–ˆ β–’β–’ β–ˆβ–ˆβ–ˆβ–ˆ β–’β–’β–‘β–‘ β–’β–’β–’β–’ "); + println!(" β–’β–’ β–’β–’β–’β–’β–’β–’ β–’β–’β–’β–’β–’β–’ β–’β–’β–’β–’β–’β–’ β–’β–’ "); + println!(" β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–“β–“β–“β–“β–“β–“β–’β–’β–’β–’β–’β–’β–’β–’β–“β–“β–’β–’β–“β–“β–’β–’β–’β–’β–’β–’β–’β–’ "); println!(" β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’ "); println!(" β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–ˆβ–ˆβ–’β–’β–’β–’β–’β–’β–ˆβ–ˆβ–’β–’β–’β–’β–’β–’β–’β–’β–’β–’ "); - println!(" β–’β–’ β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–’β–’β–’β–’β–’β–’β–’β–’β–’β–’ β–’β–’ "); - println!(" β–’β–’ β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’ β–’β–’ "); - println!(" β–’β–’ β–’β–’ β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’ β–’β–’ β–’β–’ "); - println!(" β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’ "); + println!(" β–’β–’ β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–’β–’β–’β–’β–’β–’β–’β–’β–’β–’ β–’β–’ "); + println!(" β–’β–’ β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’ β–’β–’ "); + println!(" β–’β–’ β–’β–’ β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’ β–’β–’ β–’β–’ "); + println!(" β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’ "); println!(" β–’β–’ β–’β–’ β–’β–’ β–’β–’ "); println!(); println!("We hope you enjoyed learning about the various aspects of Rust!"); @@ -223,7 +309,13 @@ fn watch(exercises: &[Exercise], verbose: bool) -> notify::Result<()> { let filepath = b.as_path().canonicalize().unwrap(); let pending_exercises = exercises .iter() - .skip_while(|e| !filepath.ends_with(&e.path)); + .skip_while(|e| !filepath.ends_with(&e.path)) + // .filter(|e| filepath.ends_with(&e.path)) + .chain( + exercises + .iter() + .filter(|e| !e.looks_done() && !filepath.ends_with(&e.path)) + ); clear_screen(); match verify(pending_exercises, verbose) { Ok(_) => return Ok(()), diff --git a/tests/fixture/state/info.toml b/tests/fixture/state/info.toml index 7bfc697e..547b3a48 100644 --- a/tests/fixture/state/info.toml +++ b/tests/fixture/state/info.toml @@ -9,3 +9,10 @@ name = "pending_test_exercise" path = "pending_test_exercise.rs" mode = "test" hint = """""" + +[[exercises]] +name = "finished_exercise" +path = "finished_exercise.rs" +mode = "compile" +hint = """""" + diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs index 2baf9b86..f5211b64 100644 --- a/tests/integration_tests.rs +++ b/tests/integration_tests.rs @@ -181,3 +181,81 @@ fn run_single_test_success_without_output() { .code(0) .stdout(predicates::str::contains("THIS TEST TOO SHALL PAS").not()); } + +#[test] +fn run_rustlings_list() { + Command::cargo_bin("rustlings") + .unwrap() + .args(&["list"]) + .current_dir("tests/fixture/success") + .assert() + .success(); +} + +#[test] +fn run_rustlings_list_conflicting_display_options() { + Command::cargo_bin("rustlings") + .unwrap() + .args(&["list", "--names", "--paths"]) + .current_dir("tests/fixture/success") + .assert() + .failure(); +} + +#[test] +fn run_rustlings_list_conflicting_solve_options() { + Command::cargo_bin("rustlings") + .unwrap() + .args(&["list", "--solved", "--unsolved"]) + .current_dir("tests/fixture/success") + .assert() + .failure(); +} + +#[test] +fn run_rustlings_list_no_pending() { + Command::cargo_bin("rustlings") + .unwrap() + .args(&["list"]) + .current_dir("tests/fixture/success") + .assert() + .success() + .stdout(predicates::str::contains("Pending").not()); +} + +#[test] +fn run_rustlings_list_both_done_and_pending() { + Command::cargo_bin("rustlings") + .unwrap() + .args(&["list"]) + .current_dir("tests/fixture/state") + .assert() + .success() + .stdout( + predicates::str::contains("Done") + .and(predicates::str::contains("Pending")) + ); +} + +#[test] +fn run_rustlings_list_without_pending() { + Command::cargo_bin("rustlings") + .unwrap() + .args(&["list", "--solved"]) + .current_dir("tests/fixture/state") + .assert() + .success() + .stdout(predicates::str::contains("Pending").not()); +} + +#[test] +fn run_rustlings_list_without_done() { + Command::cargo_bin("rustlings") + .unwrap() + .args(&["list", "--unsolved"]) + .current_dir("tests/fixture/state") + .assert() + .success() + .stdout(predicates::str::contains("Done").not()); +} + From 9f988bfe29e1146cd7dc95c68dd6863e77433553 Mon Sep 17 00:00:00 2001 From: mokou Date: Sun, 17 Jan 2021 13:00:50 +0100 Subject: [PATCH 115/282] docs: Remove duplicate uninstallation section --- README.md | 7 ------- 1 file changed, 7 deletions(-) diff --git a/README.md b/README.md index 987bb839..369bfab7 100644 --- a/README.md +++ b/README.md @@ -112,13 +112,6 @@ After every couple of sections, there will be a quiz that'll test your knowledge Once you've completed Rustlings, put your new knowledge to good use! Continue practicing your Rust skills by building your own projects, contributing to Rustlings, or finding other open-source projects to contribute to. -If you'd like to uninstall Rustlings, you can do so by invoking cargo and removing the rustlings directory: - -```bash -cargo uninstall rustlings -rm -r rustlings/ # or on Windows: rmdir /s rustlings -``` - ## Uninstalling Rustlings If you want to remove Rustlings from your system, there's two steps. First, you'll need to remove the exercises folder that the install script created From 15e71535f37cfaed36e22eb778728d186e2104ab Mon Sep 17 00:00:00 2001 From: Jean-Francois Chevrette Date: Thu, 21 Jan 2021 07:55:22 -0500 Subject: [PATCH 116/282] fix(from_str): test for error instead of unwrap/should_panic --- exercises/conversions/from_str.rs | 36 +++++++++++++------------------ 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/exercises/conversions/from_str.rs b/exercises/conversions/from_str.rs index 70ed1796..558a9033 100644 --- a/exercises/conversions/from_str.rs +++ b/exercises/conversions/from_str.rs @@ -11,15 +11,17 @@ struct Person { } // I AM NOT DONE + // Steps: -// 1. If the length of the provided string is 0, then return an error +// 1. If the length of the provided string is 0 an error should be returned // 2. Split the given string on the commas present in it -// 3. Extract the first element from the split operation and use it as the name -// 4. If the name is empty, then return an error +// 3. Only 2 elements should returned from the split, otherwise return an error +// 4. Extract the first element from the split operation and use it as the name // 5. Extract the other element from the split operation and parse it into a `usize` as the age // with something like `"4".parse::()`. -// If while parsing the age, something goes wrong, then return an error -// Otherwise, then return a Result of a Person object +// 5. If while extracting the name and the age something goes wrong an error should be returned +// If everything goes well, then return a Result of a Person object + impl FromStr for Person { type Err = String; fn from_str(s: &str) -> Result { @@ -48,50 +50,42 @@ mod tests { assert_eq!(p.age, 32); } #[test] - #[should_panic] fn missing_age() { - "John,".parse::().unwrap(); + assert!("John,".parse::().is_err()); } #[test] - #[should_panic] fn invalid_age() { - "John,twenty".parse::().unwrap(); + assert!("John,twenty".parse::().is_err()); } #[test] - #[should_panic] fn missing_comma_and_age() { - "John".parse::().unwrap(); + assert!("John".parse::().is_err()); } #[test] - #[should_panic] fn missing_name() { - ",1".parse::().unwrap(); + assert!(",1".parse::().is_err()); } #[test] - #[should_panic] fn missing_name_and_age() { - ",".parse::().unwrap(); + assert!(",".parse::().is_err()); } #[test] - #[should_panic] fn missing_name_and_invalid_age() { - ",one".parse::().unwrap(); + assert!(",one".parse::().is_err()); } #[test] - #[should_panic] fn trailing_comma() { - "John,32,".parse::().unwrap(); + assert!("John,32,".parse::().is_err()); } #[test] - #[should_panic] fn trailing_comma_and_some_string() { - "John,32,man".parse::().unwrap(); + assert!("John,32,man".parse::().is_err()); } } From 52bde71166740880da2206553df790d47cecba54 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Fri, 22 Jan 2021 12:11:33 +0000 Subject: [PATCH 117/282] docs: update README.md [skip ci] --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 369bfab7..af97f556 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -[![All Contributors](https://img.shields.io/badge/all_contributors-72-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-73-orange.svg?style=flat-square)](#contributors-) # rustlings πŸ¦€β€οΈ @@ -250,6 +250,9 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Will Hayworth

πŸ–‹
Christian Zeller

πŸ–‹ + +
Jean-Francois Chevrette

πŸ–‹ πŸ’» + From 6102e612fa3f6255cccea4c9016078f6ea007be0 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Fri, 22 Jan 2021 12:11:34 +0000 Subject: [PATCH 118/282] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 46e68ae5..ea3d7ca2 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -673,6 +673,16 @@ "contributions": [ "content" ] + }, + { + "login": "jfchevrette", + "name": "Jean-Francois Chevrette", + "avatar_url": "https://avatars.githubusercontent.com/u/3001?v=4", + "profile": "https://github.com/jfchevrette", + "contributions": [ + "content", + "code" + ] } ], "contributorsPerLine": 8, From cddc1e86e7ec744ee644cc774a4887b1a0ded3e8 Mon Sep 17 00:00:00 2001 From: John Baber-Lucero Date: Sat, 30 Jan 2021 16:12:06 +0000 Subject: [PATCH 119/282] fix(info): Fix typo (#635) Co-authored-by: John Baber-Lucero --- info.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/info.toml b/info.toml index 23c64917..f0fed934 100644 --- a/info.toml +++ b/info.toml @@ -284,7 +284,7 @@ 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. Tuple structs are basically just named tuples. -Finally, Unit structs. These don't have and fields and are useful for generics. +Finally, Unit 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""" From 75802c14b2dbfbbf65139608f19cb94dba6d7a2c Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Sat, 30 Jan 2021 16:12:27 +0000 Subject: [PATCH 120/282] docs: update README.md [skip ci] --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index af97f556..c2e598c1 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -[![All Contributors](https://img.shields.io/badge/all_contributors-73-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-74-orange.svg?style=flat-square)](#contributors-) # rustlings πŸ¦€β€οΈ @@ -252,6 +252,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Jean-Francois Chevrette

πŸ–‹ πŸ’» +
John Baber-Lucero

πŸ–‹ From c1abd13b5c026643b5dddc85b3aa546ef75243d6 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Sat, 30 Jan 2021 16:12:28 +0000 Subject: [PATCH 121/282] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index ea3d7ca2..9cdf6b08 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -683,6 +683,15 @@ "content", "code" ] + }, + { + "login": "jbaber", + "name": "John Baber-Lucero", + "avatar_url": "https://avatars.githubusercontent.com/u/1908117?v=4", + "profile": "https://github.com/jbaber", + "contributions": [ + "content" + ] } ], "contributorsPerLine": 8, From cc266d7d80b91e79df3f61984f231b7f1587218e Mon Sep 17 00:00:00 2001 From: Tal <3195851+tal-zvon@users.noreply.github.com> Date: Sun, 7 Feb 2021 04:22:13 -0700 Subject: [PATCH 122/282] fix(move_semantics4): Remove redundant "instead" (#640) --- exercises/move_semantics/move_semantics4.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/move_semantics/move_semantics4.rs b/exercises/move_semantics/move_semantics4.rs index 6308c296..2a23c710 100644 --- a/exercises/move_semantics/move_semantics4.rs +++ b/exercises/move_semantics/move_semantics4.rs @@ -1,6 +1,6 @@ // move_semantics4.rs // Refactor this code so that instead of having `vec0` and creating the vector -// in `fn main`, we instead create it within `fn fill_vec` and transfer the +// in `fn main`, we create it within `fn fill_vec` and transfer the // freshly created vector from fill_vec to its caller. // Execute `rustlings hint move_semantics4` for hints! From 1f9d00685836cbf639a518b5612e7e16d669bf48 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Sun, 7 Feb 2021 11:22:32 +0000 Subject: [PATCH 123/282] docs: update README.md [skip ci] --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c2e598c1..fe61f6f4 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -[![All Contributors](https://img.shields.io/badge/all_contributors-74-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-75-orange.svg?style=flat-square)](#contributors-) # rustlings πŸ¦€β€οΈ @@ -253,6 +253,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Jean-Francois Chevrette

πŸ–‹ πŸ’»
John Baber-Lucero

πŸ–‹ +
Tal

πŸ–‹ From f1d2b3a39a676ae25cc0e4fb18f582441bc239e2 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Sun, 7 Feb 2021 11:22:33 +0000 Subject: [PATCH 124/282] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 9cdf6b08..6db7a29b 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -692,6 +692,15 @@ "contributions": [ "content" ] + }, + { + "login": "tal-zvon", + "name": "Tal", + "avatar_url": "https://avatars.githubusercontent.com/u/3195851?v=4", + "profile": "https://github.com/tal-zvon", + "contributions": [ + "content" + ] } ], "contributorsPerLine": 8, From 726805f064659f8cc2612974eb6d21690378cabc Mon Sep 17 00:00:00 2001 From: apogeeoak <59737221+apogeeoak@users.noreply.github.com> Date: Tue, 9 Feb 2021 17:43:53 -0500 Subject: [PATCH 125/282] docs: Fixed grammar in contributing.md. --- CONTRIBUTING.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d566df08..2ca0e341 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -26,12 +26,12 @@ isn't really that complicated since the bulk of the work is done by `rustc`. ### Adding an exercise -First step is to add the exercise! Call it `exercises/yourTopic/yourTopicN.rs`, make sure to +The first step is to add the exercise! Name the file `exercises/yourTopic/yourTopicN.rs`, make sure to put in some helpful links, and link to sections of the book in `exercises/yourTopic/README.md`. -Next you want to make sure it runs when using `rustlings`. All exercises are stored in `info.toml`, under the `exercises` array. They're ordered by the order they're ran when using `rustlings verify`. +Next make sure it runs with `rustlings`. The exercise metadata is stored in `info.toml`, under the `exercises` array. The order of the `exercises` array determines the order the exercises are run by `rustlings verify`. -You want to make sure where in the file you add your exercise. If you're not sure, add it at the bottom and ask in your pull request. To add an exercise, edit the file like this: +Add the metadata for your exercise in the correct order in the `exercises` array. If you are unsure of the correct ordering, add it at the bottom and ask in your pull request. The exercise metadata should contain the following: ```diff ... + [[exercises]] From 2e84f34cf375fa3d12c73d1f28d68f0be9de3dc4 Mon Sep 17 00:00:00 2001 From: apogeeoak <59737221+apogeeoak@users.noreply.github.com> Date: Tue, 9 Feb 2021 18:21:18 -0500 Subject: [PATCH 126/282] chore: Updated source to follow clippy suggestions. --- src/main.rs | 2 +- tests/integration_tests.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 75a9cec1..50e4a386 100644 --- a/src/main.rs +++ b/src/main.rs @@ -142,7 +142,7 @@ fn main() { let fname = format!("{}", e.path.display()); let filter_cond = filters .split(',') - .filter(|f| f.trim().len() > 0) + .filter(|f| !f.trim().is_empty()) .any(|f| e.name.contains(&f) || fname.contains(&f)); let status = if e.looks_done() { "Done" } else { "Pending" }; let solve_cond = { diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs index f5211b64..1bd3bf7e 100644 --- a/tests/integration_tests.rs +++ b/tests/integration_tests.rs @@ -131,7 +131,7 @@ fn all_exercises_require_confirmation() { file.read_to_string(&mut s).unwrap(); s }; - source.matches("// I AM NOT DONE").next().expect(&format!( + source.matches("// I AM NOT DONE").next().unwrap_or_else(|| panic!( "There should be an `I AM NOT DONE` annotation in {:?}", path )); From d65b4a9a93477745e206de11e1634ffe3cb3a6e6 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Wed, 10 Feb 2021 09:36:47 +0000 Subject: [PATCH 127/282] docs: update README.md [skip ci] --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index fe61f6f4..9e617eba 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -[![All Contributors](https://img.shields.io/badge/all_contributors-75-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-76-orange.svg?style=flat-square)](#contributors-) # rustlings πŸ¦€β€οΈ @@ -254,6 +254,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Jean-Francois Chevrette

πŸ–‹ πŸ’»
John Baber-Lucero

πŸ–‹
Tal

πŸ–‹ +
apogeeoak

πŸ–‹ πŸ’» From f5158ece1a9d9896f089a352f8a2bd7502890864 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Wed, 10 Feb 2021 09:36:48 +0000 Subject: [PATCH 128/282] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 6db7a29b..c4e68a15 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -701,6 +701,16 @@ "contributions": [ "content" ] + }, + { + "login": "apogeeoak", + "name": "apogeeoak", + "avatar_url": "https://avatars.githubusercontent.com/u/59737221?v=4", + "profile": "https://github.com/apogeeoak", + "contributions": [ + "content", + "code" + ] } ], "contributorsPerLine": 8, From b29ea17ea94d1862114af2cf5ced0e09c197dc35 Mon Sep 17 00:00:00 2001 From: apogeeoak <59737221+apogeeoak@users.noreply.github.com> Date: Wed, 10 Feb 2021 18:03:29 -0500 Subject: [PATCH 129/282] feat: Added iterators5.rs exercise. --- .../standard_library_types/iterators5.rs | 113 ++++++++++++++++++ info.toml | 15 +++ 2 files changed, 128 insertions(+) create mode 100644 exercises/standard_library_types/iterators5.rs diff --git a/exercises/standard_library_types/iterators5.rs b/exercises/standard_library_types/iterators5.rs new file mode 100644 index 00000000..65c50e62 --- /dev/null +++ b/exercises/standard_library_types/iterators5.rs @@ -0,0 +1,113 @@ +// iterators5.rs + +// Rustling progress is modelled using a hash map. The name of the exercise is +// the key and the progress is the value. Two counting functions were created +// to count the number of exercises with a given progress. These counting +// functions use imperative style for loops. Recreate this counting +// functionality using iterators. +// Execute `rustlings hint iterators5` for hints. +// +// Make the code compile and the tests pass. + +// I AM NOT DONE + +use std::collections::HashMap; + +#[derive(PartialEq, Eq)] +enum Progress { + None, + Some, + Complete, +} + +fn count_for(map: &HashMap, value: Progress) -> usize { + let mut count = 0; + for val in map.values() { + if val == &value { + count += 1; + } + } + count +} + +fn count(map: &HashMap, value: Progress) -> usize { +} + +fn count_stack_for(stack: &[HashMap], value: Progress) -> usize { + let mut count = 0; + for map in stack { + for val in map.values() { + if val == &value { + count += 1; + } + } + } + count +} + +fn count_stack(stack: &[HashMap], value: Progress) -> usize { +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn count_complete() { + let map = get_map(); + assert_eq!(3, count(&map, Progress::Complete)); + } + + #[test] + fn count_equals_for() { + let map = get_map(); + assert_eq!( + count_for(&map, Progress::Complete), + count(&map, Progress::Complete) + ); + } + + #[test] + fn count_stack_complete() { + let stack = get_map_stack(); + assert_eq!(6, count_stack(&stack, Progress::Complete)); + } + + #[test] + fn count_stack_equals_for() { + let stack = get_map_stack(); + assert_eq!( + count_stack_for(&stack, Progress::Complete), + count_stack(&stack, Progress::Complete) + ); + } + + fn get_map() -> HashMap { + use Progress::*; + + let mut map = HashMap::new(); + map.insert(String::from("variables1"), Complete); + map.insert(String::from("functions1"), Complete); + map.insert(String::from("hashmap1"), Complete); + map.insert(String::from("arc1"), Some); + map.insert(String::from("as_ref_mut"), None); + map.insert(String::from("from_str"), None); + + map + } + + fn get_map_stack() -> Vec> { + use Progress::*; + + let map = get_map(); + + let mut other = HashMap::new(); + other.insert(String::from("variables2"), Complete); + other.insert(String::from("functions2"), Complete); + other.insert(String::from("if1"), Complete); + other.insert(String::from("from_into"), None); + other.insert(String::from("try_from_into"), None); + + vec![map, other] + } +} diff --git a/info.toml b/info.toml index f0fed934..646bb5a5 100644 --- a/info.toml +++ b/info.toml @@ -741,6 +741,21 @@ 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.""" +[[exercises]] +name = "iterators5" +path = "exercises/standard_library_types/iterators5.rs" +mode = "test" +hint = """ +The documentation for the std::iter::Iterator trait contains numerous methods +that would be helpful here. + +Return 0 from count_stack to make the code compile in order to test count. + +The stack variable in count_stack is a slice of HashMaps. It needs to be +converted into an iterator in order to use the iterator methods. + +The fold method can be useful in the count_stack function.""" + # THREADS [[exercises]] From baf4ba175ba6eb92989e3dd54ecbec4bedc9a863 Mon Sep 17 00:00:00 2001 From: apogeeoak <59737221+apogeeoak@users.noreply.github.com> Date: Thu, 11 Feb 2021 21:24:32 -0500 Subject: [PATCH 130/282] fix(iterators2): Moved errors out of tests. Closes #359 --- .../standard_library_types/iterators2.rs | 38 ++++++++++++------- info.toml | 19 +++++----- 2 files changed, 33 insertions(+), 24 deletions(-) diff --git a/exercises/standard_library_types/iterators2.rs b/exercises/standard_library_types/iterators2.rs index 84d14ae6..87b4eaa1 100644 --- a/exercises/standard_library_types/iterators2.rs +++ b/exercises/standard_library_types/iterators2.rs @@ -1,28 +1,41 @@ // iterators2.rs -// In this module, you'll learn some of the unique advantages that iterators can offer. -// Step 1. Complete the `capitalize_first` function to pass the first two cases. -// Step 2. Apply the `capitalize_first` function to a vector of strings. -// Ensure that it returns a vector of strings as well. -// Step 3. Apply the `capitalize_first` function again to a list. -// Try to ensure it returns a single string. +// In this exercise, you'll learn some of the unique advantages that iterators +// can offer. Follow the steps to complete the exercise. // As always, there are hints if you execute `rustlings hint iterators2`! // I AM NOT DONE +// Step 1. +// Complete the `capitalize_first` function. +// "hello" -> "Hello" pub fn capitalize_first(input: &str) -> String { let mut c = input.chars(); match c.next() { None => String::new(), - Some(first) => first.collect::() + c.as_str(), + Some(first) => ???, } } +// Step 2. +// Apply the `capitalize_first` function to a slice of string slices. +// Return a vector of strings. +// ["hello", "world"] -> ["Hello", "World"] +pub fn capitalize_words_vector(words: &[&str]) -> Vec { + vec![] +} + +// Step 3. +// Apply the `capitalize_first` function again to a slice of string slices. +// Return a single string. +// ["hello", " ", "world"] -> "Hello World" +pub fn capitalize_words_string(words: &[&str]) -> String { + String::new() +} + #[cfg(test)] mod tests { use super::*; - // Step 1. - // Tests that verify your `capitalize_first` function implementation #[test] fn test_success() { assert_eq!(capitalize_first("hello"), "Hello"); @@ -33,18 +46,15 @@ mod tests { assert_eq!(capitalize_first(""), ""); } - // Step 2. #[test] fn test_iterate_string_vec() { let words = vec!["hello", "world"]; - let capitalized_words: Vec = // TODO - assert_eq!(capitalized_words, ["Hello", "World"]); + assert_eq!(capitalize_words_vector(&words), ["Hello", "World"]); } #[test] fn test_iterate_into_string() { let words = vec!["hello", " ", "world"]; - let capitalized_words = // TODO - assert_eq!(capitalized_words, "Hello World"); + assert_eq!(capitalize_words_string(&words), "Hello World"); } } diff --git a/info.toml b/info.toml index f0fed934..5570b01c 100644 --- a/info.toml +++ b/info.toml @@ -704,21 +704,20 @@ path = "exercises/standard_library_types/iterators2.rs" mode = "test" hint = """ Step 1 -You need to call something on `first` before it can be collected -Currently its type is `char`. Have a look at the methods that are available on that type: +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 -First you'll need to turn the Vec into an iterator -Then you'll need to apply your function unto each item in the vector -P.s. Don't forget to collect() at the end! - +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 very similar to the previous test. The only real change is that you will need to -alter the type that collect is coerced into. For a bonus you could try doing this with a -turbofish""" +This is surprising similar to the previous solution. Collect is very powerful +and very general. Rust just needs to know the desired type.""" [[exercises]] name = "iterators3" From c6712dfccd1a093e590ad22bbc4f49edc417dac0 Mon Sep 17 00:00:00 2001 From: apogeeoak <59737221+apogeeoak@users.noreply.github.com> Date: Fri, 12 Feb 2021 15:36:53 -0500 Subject: [PATCH 131/282] fix(iterators3): Enabled iterators3.rs to run without commented out tests. --- .../standard_library_types/iterators3.rs | 47 ++++++++++--------- info.toml | 12 +++-- 2 files changed, 34 insertions(+), 25 deletions(-) diff --git a/exercises/standard_library_types/iterators3.rs b/exercises/standard_library_types/iterators3.rs index 353cea62..8c66c05b 100644 --- a/exercises/standard_library_types/iterators3.rs +++ b/exercises/standard_library_types/iterators3.rs @@ -1,11 +1,10 @@ // iterators3.rs // This is a bigger exercise than most of the others! You can do it! // Here is your mission, should you choose to accept it: -// 1. Complete the divide function to get the first four tests to pass -// 2. Uncomment the last two tests and get them to pass by filling in -// values for `x` using `division_results`. +// 1. Complete the divide function to get the first four tests to pass. +// 2. Get the remaining tests to pass by completing the result_with_list and +// list_of_results functions. // Execute `rustlings hint iterators3` to get some hints! -// Have fun :-) // I AM NOT DONE @@ -21,16 +20,28 @@ pub struct NotDivisibleError { divisor: i32, } -// This function should calculate `a` divided by `b` if `a` is -// evenly divisible by b. -// Otherwise, it should return a suitable error. +// Calculate `a` divided by `b` if `a` is evenly divisible by `b`. +// Otherwise, return a suitable error. pub fn divide(a: i32, b: i32) -> Result {} +// Complete the function and return a value of the correct type so the test passes. +// Desired output: Ok([1, 11, 1426, 3]) +fn result_with_list() -> () { + let numbers = vec![27, 297, 38502, 81]; + let division_results = numbers.into_iter().map(|n| divide(n, 27)); +} + +// Complete the function and return a value of the correct type so the test passes. +// Desired output: [Ok(1), Ok(11), Ok(1426), Ok(3)] +fn list_of_results() -> () { + let numbers = vec![27, 297, 38502, 81]; + let division_results = numbers.into_iter().map(|n| divide(n, 27)); +} + #[cfg(test)] mod tests { use super::*; - // Tests that verify your `divide` function implementation #[test] fn test_success() { assert_eq!(divide(81, 9), Ok(9)); @@ -57,22 +68,16 @@ mod tests { assert_eq!(divide(0, 81), Ok(0)); } - // Iterator exercises using your `divide` function - /* #[test] - fn result_with_list() { - let numbers = vec![27, 297, 38502, 81]; - let division_results = numbers.into_iter().map(|n| divide(n, 27)); - let x //... Fill in here! - assert_eq!(format!("{:?}", x), "Ok([1, 11, 1426, 3])"); + fn test_result_with_list() { + assert_eq!(format!("{:?}", result_with_list()), "Ok([1, 11, 1426, 3])"); } #[test] - fn list_of_results() { - let numbers = vec![27, 297, 38502, 81]; - let division_results = numbers.into_iter().map(|n| divide(n, 27)); - let x //... Fill in here! - assert_eq!(format!("{:?}", x), "[Ok(1), Ok(11), Ok(1426), Ok(3)]"); + fn test_list_of_results() { + assert_eq!( + format!("{:?}", list_of_results()), + "[Ok(1), Ok(11), Ok(1426), Ok(3)]" + ); } - */ } diff --git a/info.toml b/info.toml index f0fed934..73c5672c 100644 --- a/info.toml +++ b/info.toml @@ -725,11 +725,15 @@ name = "iterators3" path = "exercises/standard_library_types/iterators3.rs" mode = "test" hint = """ -Minor hint: In each of the two cases in the match in main, you can create x with either -a 'turbofish' or by hinting the type of x to the compiler. You may try both. +The divide function needs to return the correct error when even division is not +possible. -Major hint: Have a look at the Iter trait and at the explanation of its collect function. -Especially the part about Result is interesting.""" +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 list_of_results function needs to return a vector of results.""" [[exercises]] name = "iterators4" From 5f7c89f85db1f33da01911eaa479c3a2d4721678 Mon Sep 17 00:00:00 2001 From: Jirka Kremser <535866+jkremser@users.noreply.github.com> Date: Sun, 21 Feb 2021 21:50:17 +0100 Subject: [PATCH 132/282] fix(from_str): Correct typos typos in the comments --- exercises/conversions/from_str.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/exercises/conversions/from_str.rs b/exercises/conversions/from_str.rs index 558a9033..41fccd7e 100644 --- a/exercises/conversions/from_str.rs +++ b/exercises/conversions/from_str.rs @@ -13,13 +13,13 @@ struct Person { // I AM NOT DONE // Steps: -// 1. If the length of the provided string is 0 an error should be returned +// 1. If the length of the provided string is 0, an error should be returned // 2. Split the given string on the commas present in it -// 3. Only 2 elements should returned from the split, otherwise return an error +// 3. Only 2 elements should be returned from the split, otherwise return an error // 4. Extract the first element from the split operation and use it as the name // 5. Extract the other element from the split operation and parse it into a `usize` as the age -// with something like `"4".parse::()`. -// 5. If while extracting the name and the age something goes wrong an error should be returned +// with something like `"4".parse::()` +// 5. If while extracting the name and the age something goes wrong, an error should be returned // If everything goes well, then return a Result of a Person object impl FromStr for Person { From 91ee27f22bd3797a9db57e5fd430801c170c5db8 Mon Sep 17 00:00:00 2001 From: Larry Garfield Date: Wed, 24 Feb 2021 15:03:26 -0600 Subject: [PATCH 133/282] fix: Spelling error --- src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 50e4a386..569aa4ac 100644 --- a/src/main.rs +++ b/src/main.rs @@ -213,7 +213,7 @@ fn main() { if matches.subcommand_matches("watch").is_some() { if let Err(e) = watch(&exercises, verbose) { println!( - "Error: Could not watch your progess. Error message was {:?}.", + "Error: Could not watch your progress. Error message was {:?}.", e ); println!("Most likely you've run out of disk space or your 'inotify limit' has been reached."); From 320de0d92184fc0c4467a8cb5ac4af3b8fdcde6e Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Thu, 25 Feb 2021 10:20:53 +0000 Subject: [PATCH 134/282] docs: update README.md [skip ci] --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9e617eba..8f7feb76 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -[![All Contributors](https://img.shields.io/badge/all_contributors-76-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-77-orange.svg?style=flat-square)](#contributors-) # rustlings πŸ¦€β€οΈ @@ -255,6 +255,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
John Baber-Lucero

πŸ–‹
Tal

πŸ–‹
apogeeoak

πŸ–‹ πŸ’» +
Larry Garfield

πŸ–‹ From 797e6d45c04c1833cbe608ca0c9af648e5373e25 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Thu, 25 Feb 2021 10:20:54 +0000 Subject: [PATCH 135/282] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index c4e68a15..3c2a0bb3 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -711,6 +711,15 @@ "content", "code" ] + }, + { + "login": "Crell", + "name": "Larry Garfield", + "avatar_url": "https://avatars.githubusercontent.com/u/254863?v=4", + "profile": "http://www.garfieldtech.com/", + "contributions": [ + "content" + ] } ], "contributorsPerLine": 8, From 833df0b8b3bcc03df50f76f3b9ed15c5ffc60870 Mon Sep 17 00:00:00 2001 From: circumspect <40770208+circumspect@users.noreply.github.com> Date: Fri, 12 Mar 2021 14:26:57 +0000 Subject: [PATCH 136/282] chore: fix typo Co-authored-by: Chenkail <40770208+Chenkail@users.noreply.github.com> --- src/exercise.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/exercise.rs b/src/exercise.rs index 7afa230a..18e8d5ab 100644 --- a/src/exercise.rs +++ b/src/exercise.rs @@ -235,7 +235,7 @@ path = "{}.rs""#, // Check that the exercise looks to be solved using self.state() // This is not the best way to check since - // the user can just remove the "I AM NOT DONE" string fromm the file + // the user can just remove the "I AM NOT DONE" string from the file // without actually having solved anything. // The only other way to truly check this would to compile and run // the exercise; which would be both costly and counterintuitive From 3f5abca21535537dfcef69adaf2b08df790e47fa Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Fri, 12 Mar 2021 15:28:03 +0100 Subject: [PATCH 137/282] docs: add circumspect as a contributor * docs: update README.md [skip ci] * docs: update .all-contributorsrc [skip ci] Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com> --- .all-contributorsrc | 9 +++++++++ README.md | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index 3c2a0bb3..9aa0630a 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -720,6 +720,15 @@ "contributions": [ "content" ] + }, + { + "login": "circumspect", + "name": "circumspect", + "avatar_url": "https://avatars.githubusercontent.com/u/40770208?v=4", + "profile": "https://github.com/circumspect", + "contributions": [ + "content" + ] } ], "contributorsPerLine": 8, diff --git a/README.md b/README.md index 8f7feb76..97790643 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -[![All Contributors](https://img.shields.io/badge/all_contributors-77-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-78-orange.svg?style=flat-square)](#contributors-) # rustlings πŸ¦€β€οΈ @@ -256,6 +256,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Tal

πŸ–‹
apogeeoak

πŸ–‹ πŸ’»
Larry Garfield

πŸ–‹ +
circumspect

πŸ–‹ From 5157f568753737bab860831d13fe342dec27b242 Mon Sep 17 00:00:00 2001 From: Cyrus Wyett <34195737+cjwyett@users.noreply.github.com> Date: Fri, 12 Mar 2021 14:38:28 +0000 Subject: [PATCH 138/282] chore: fix typo is however some --> are however some --- info.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/info.toml b/info.toml index f0fed934..b37306c3 100644 --- a/info.toml +++ b/info.toml @@ -295,7 +295,7 @@ 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. -There is however some shortcuts that can be taken when instantiating structs. +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""" [[exercises]] From 815edb7003c58f60c6baecb7d91cd72614be7ad6 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Fri, 12 Mar 2021 15:39:40 +0100 Subject: [PATCH 139/282] docs: add cjwyett as a contributor (#666) * docs: update README.md [skip ci] * docs: update .all-contributorsrc [skip ci] Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com> --- .all-contributorsrc | 9 +++++++++ README.md | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index 9aa0630a..4eab3c6b 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -729,6 +729,15 @@ "contributions": [ "content" ] + }, + { + "login": "cjwyett", + "name": "Cyrus Wyett", + "avatar_url": "https://avatars.githubusercontent.com/u/34195737?v=4", + "profile": "https://github.com/cjwyett", + "contributions": [ + "content" + ] } ], "contributorsPerLine": 8, diff --git a/README.md b/README.md index 97790643..ca99796f 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -[![All Contributors](https://img.shields.io/badge/all_contributors-78-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-79-orange.svg?style=flat-square)](#contributors-) # rustlings πŸ¦€β€οΈ @@ -257,6 +257,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
apogeeoak

πŸ–‹ πŸ’»
Larry Garfield

πŸ–‹
circumspect

πŸ–‹ +
Cyrus Wyett

πŸ–‹ From 05a753fe6333d36dbee5f68c21dec04eacdc75df Mon Sep 17 00:00:00 2001 From: cadolphs Date: Fri, 12 Mar 2021 09:36:35 -0800 Subject: [PATCH 140/282] fix: add check to prevent naive implementation of is_international * fix(structs3): Add check to prevent naive implementation * chore(structs3): Add a missed newline after the test I added --- exercises/structs/structs3.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/exercises/structs/structs3.rs b/exercises/structs/structs3.rs index 06fcaf29..f18cc925 100644 --- a/exercises/structs/structs3.rs +++ b/exercises/structs/structs3.rs @@ -57,6 +57,16 @@ mod tests { assert!(package.is_international()); } + #[test] + fn create_local_package() { + let sender_country = String::from("Canada"); + let recipient_country = sender_country.clone(); + + let package = Package::new(sender_country, recipient_country, 1200); + + assert!(!package.is_international()); + } + #[test] fn calculate_transport_fees() { let sender_country = String::from("Spain"); From 04dbf03ace1bc7f23f5f98bb701cba8505954c39 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Fri, 12 Mar 2021 18:37:58 +0100 Subject: [PATCH 141/282] docs: add cadolphs as a contributor (#667) * docs: update README.md [skip ci] * docs: update .all-contributorsrc [skip ci] Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com> --- .all-contributorsrc | 9 +++++++++ README.md | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index 4eab3c6b..45ea4b75 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -738,6 +738,15 @@ "contributions": [ "content" ] + }, + { + "login": "cadolphs", + "name": "cadolphs", + "avatar_url": "https://avatars.githubusercontent.com/u/13894820?v=4", + "profile": "https://github.com/cadolphs", + "contributions": [ + "code" + ] } ], "contributorsPerLine": 8, diff --git a/README.md b/README.md index ca99796f..b958fae6 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -[![All Contributors](https://img.shields.io/badge/all_contributors-79-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-80-orange.svg?style=flat-square)](#contributors-) # rustlings πŸ¦€β€οΈ @@ -258,6 +258,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Larry Garfield

πŸ–‹
circumspect

πŸ–‹
Cyrus Wyett

πŸ–‹ +
cadolphs

πŸ’» From 96c56ab08a30835e9f4d2b6b83b75a0060726fbd Mon Sep 17 00:00:00 2001 From: apogeeoak <59737221+apogeeoak@users.noreply.github.com> Date: Fri, 12 Mar 2021 14:04:29 -0500 Subject: [PATCH 142/282] chore: changed errors3 mode from test to compile --- info.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/info.toml b/info.toml index b37306c3..2068750a 100644 --- a/info.toml +++ b/info.toml @@ -470,7 +470,7 @@ and give it a try!""" [[exercises]] name = "errors3" path = "exercises/error_handling/errors3.rs" -mode = "test" +mode = "compile" hint = """ If other functions can return a `Result`, why shouldn't `main`?""" @@ -694,7 +694,7 @@ Step 2 & step 2.1: Very similar to the lines above and below. You've got this! Step 3: 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 +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. """ From 9f3e8c2dde645e5264c2d2200e68842b5f47bfa3 Mon Sep 17 00:00:00 2001 From: Darius Wiles Date: Sat, 13 Mar 2021 03:14:02 -0800 Subject: [PATCH 143/282] fix(structs3): reword heading comment (#664) --- exercises/structs/structs3.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/exercises/structs/structs3.rs b/exercises/structs/structs3.rs index f18cc925..8d8b4710 100644 --- a/exercises/structs/structs3.rs +++ b/exercises/structs/structs3.rs @@ -1,7 +1,8 @@ // structs3.rs -// Structs contain more than simply some data, they can also have logic, in this -// exercise we have defined the Package struct and we want to test some logic attached to it, -// make the code compile and the tests pass! If you have issues execute `rustlings hint structs3` +// Structs contain data, but can also have logic. In this exercise we have +// defined the Package struct and we want to test some logic attached to it. +// Make the code compile and the tests pass! +// If you have issues execute `rustlings hint structs3` // I AM NOT DONE From ebdb66c7bfb6d687a14cc511a559a222e6fc5de4 Mon Sep 17 00:00:00 2001 From: Darius Wiles Date: Sat, 13 Mar 2021 03:14:44 -0800 Subject: [PATCH 144/282] fix(structs2): correct grammar in hint (#663) From aa9a943ddf3ae260782e73c26bcc9db60e5894b6 Mon Sep 17 00:00:00 2001 From: Ivan Nerazumov <64264529+cseltol@users.noreply.github.com> Date: Sat, 13 Mar 2021 18:45:52 +0700 Subject: [PATCH 145/282] fix(installation): first PowerShell command ExecutionPolicy to RemoteSigned command was fixed because the old command was getting denied access to change the Execution Policy property --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b958fae6..3b7ff168 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ This will install Rustlings and give you access to the `rustlings` command. Run In PowerShell, set `ExecutionPolicy` to `RemoteSigned`: ```ps -Set-ExecutionPolicy RemoteSigned +Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser ``` Then, you can run: From 3bce2ef8d6a613f6601328b3679ec18256cefec9 Mon Sep 17 00:00:00 2001 From: Pascal H Date: Mon, 15 Mar 2021 09:14:12 +0100 Subject: [PATCH 146/282] chore: clarify collections documentation C++ `map` is more like BTreeMap. `unordered_map` in C++(11) is the equivalent of `HashMap` in Rust. (+ additional like for references). --- exercises/collections/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exercises/collections/README.md b/exercises/collections/README.md index 9ded29a0..af87863b 100644 --- a/exercises/collections/README.md +++ b/exercises/collections/README.md @@ -14,7 +14,7 @@ structures that are used very often in Rust programs: * A *vector* allows you to store a variable number of values next to each other. * A *hash map* allows you to associate a value with a particular key. - You may also know this by the names *map* in C++, *dictionary* in - Python or an *associative array* in other languages. + You may also know this by the names [*unordered map* in C++](https://en.cppreference.com/w/cpp/container/unordered_map), + [*dictionary* in Python](https://docs.python.org/3/tutorial/datastructures.html#dictionaries) or an *associative array* in other languages. [Rust book chapter](https://doc.rust-lang.org/stable/book/ch08-01-vectors.html) From be9510539e84c869362f6cd3fa6f791d3e02a821 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Mon, 15 Mar 2021 09:14:41 +0100 Subject: [PATCH 147/282] docs: add hpwxf as a contributor (#671) * docs: update README.md [skip ci] * docs: update .all-contributorsrc [skip ci] Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com> --- .all-contributorsrc | 9 +++++++++ README.md | 5 ++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index 45ea4b75..5239b29c 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -747,6 +747,15 @@ "contributions": [ "code" ] + }, + { + "login": "hpwxf", + "name": "Pascal H.", + "avatar_url": "https://avatars.githubusercontent.com/u/26146722?v=4", + "profile": "https://www.haveneer.com", + "contributions": [ + "content" + ] } ], "contributorsPerLine": 8, diff --git a/README.md b/README.md index b958fae6..85bba46d 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -[![All Contributors](https://img.shields.io/badge/all_contributors-80-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-81-orange.svg?style=flat-square)](#contributors-) # rustlings πŸ¦€β€οΈ @@ -260,6 +260,9 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Cyrus Wyett

πŸ–‹
cadolphs

πŸ’» + +
Pascal H.

πŸ–‹ + From 0d894e6ff739943901e1ae8c904582e5c2f843bd Mon Sep 17 00:00:00 2001 From: Pascal H Date: Tue, 16 Mar 2021 10:14:25 +0100 Subject: [PATCH 148/282] fix(quiz3): Force an answer to Q2 (#672) Add also an example of unimplemented!() macro. --- exercises/quiz3.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/exercises/quiz3.rs b/exercises/quiz3.rs index a0cd3712..fae0eedb 100644 --- a/exercises/quiz3.rs +++ b/exercises/quiz3.rs @@ -24,6 +24,7 @@ mod tests { #[test] fn returns_twice_of_negative_numbers() { - // TODO write an assert for `times_two(-4)` + // TODO replace unimplemented!() with an assert for `times_two(-4)` + unimplemented!() } } From bef39b125961310b34b34871e480a82e82af4678 Mon Sep 17 00:00:00 2001 From: Mickael Fortunato Date: Thu, 18 Mar 2021 18:39:22 +0100 Subject: [PATCH 149/282] fix(collections): Naming exercises for vectors and hashmap --- exercises/collections/vec2.rs | 7 +------ info.toml | 8 ++++---- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/exercises/collections/vec2.rs b/exercises/collections/vec2.rs index ec6cfc00..08b6bbf5 100644 --- a/exercises/collections/vec2.rs +++ b/exercises/collections/vec2.rs @@ -28,11 +28,6 @@ mod tests { let v: Vec = (1..).filter(|x| x % 2 == 0).take(5).collect(); let ans = vec_loop(v.clone()); - assert_eq!( - ans, - v.iter() - .map(|x| x * 2) - .collect::>() - ); + assert_eq!(ans, v.iter().map(|x| x * 2).collect::>()); } } diff --git a/info.toml b/info.toml index 2068750a..baae76af 100644 --- a/info.toml +++ b/info.toml @@ -359,7 +359,7 @@ each constant.""" # COLLECTIONS [[exercises]] -name = "collections1" +name = "vec1" path = "exercises/collections/vec1.rs" mode = "test" hint = """ @@ -373,7 +373,7 @@ of the Rust book to learn more. """ [[exercises]] -name = "collections2" +name = "vec2" path = "exercises/collections/vec2.rs" mode = "test" hint = """ @@ -383,7 +383,7 @@ Hint 2: Check the suggestion from the compiler error ;) """ [[exercises]] -name = "collections3" +name = "hashmap1" path = "exercises/collections/hashmap1.rs" mode = "test" hint = """ @@ -394,7 +394,7 @@ Hint 2: Number of fruits should be at least 5. And you have to put """ [[exercises]] -name = "collections4" +name = "hashmap2" path = "exercises/collections/hashmap2.rs" mode = "test" hint = """ From ab9995e76e10fb1159f9ca1f378e3e11838dc5bc Mon Sep 17 00:00:00 2001 From: Mickael Fortunato Date: Thu, 18 Mar 2021 18:45:01 +0100 Subject: [PATCH 150/282] doc: Update collections exercises instruction to match the standard naming --- exercises/collections/hashmap1.rs | 6 ++---- exercises/collections/hashmap2.rs | 6 ++---- exercises/collections/vec1.rs | 2 +- exercises/collections/vec2.rs | 2 +- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/exercises/collections/hashmap1.rs b/exercises/collections/hashmap1.rs index b1dc0bbd..64b5a7f3 100644 --- a/exercises/collections/hashmap1.rs +++ b/exercises/collections/hashmap1.rs @@ -8,7 +8,7 @@ // // Make me compile and pass the tests! // -// Execute the command `rustlings hint collections3` if you need +// Execute the command `rustlings hint hashmap1` if you need // hints. // I AM NOT DONE @@ -39,8 +39,6 @@ mod tests { #[test] fn at_least_five_fruits() { let basket = fruit_basket(); - assert!(basket - .values() - .sum::() >= 5); + assert!(basket.values().sum::() >= 5); } } diff --git a/exercises/collections/hashmap2.rs b/exercises/collections/hashmap2.rs index 7e25be7c..f865fe1c 100644 --- a/exercises/collections/hashmap2.rs +++ b/exercises/collections/hashmap2.rs @@ -9,7 +9,7 @@ // // Make me pass the tests! // -// Execute the command `rustlings hint collections4` if you need +// Execute the command `rustlings hint hashmap2` if you need // hints. // I AM NOT DONE @@ -75,9 +75,7 @@ mod tests { fn greater_than_eleven_fruits() { let mut basket = get_fruit_basket(); fruit_basket(&mut basket); - let count = basket - .values() - .sum::(); + let count = basket.values().sum::(); assert!(count > 11); } } diff --git a/exercises/collections/vec1.rs b/exercises/collections/vec1.rs index f6bc837c..b144fb94 100644 --- a/exercises/collections/vec1.rs +++ b/exercises/collections/vec1.rs @@ -2,7 +2,7 @@ // Your task is to create a `Vec` which holds the exact same elements // as in the array `a`. // Make me compile and pass the test! -// Execute the command `rustlings hint collections1` if you need hints. +// Execute the command `rustlings hint vec1` if you need hints. // I AM NOT DONE diff --git a/exercises/collections/vec2.rs b/exercises/collections/vec2.rs index 08b6bbf5..6595e401 100644 --- a/exercises/collections/vec2.rs +++ b/exercises/collections/vec2.rs @@ -4,7 +4,7 @@ // // Make me pass the test! // -// Execute the command `rustlings hint collections2` if you need +// Execute the command `rustlings hint vec2` if you need // hints. // I AM NOT DONE From 8d62a9963708dbecd9312e8bcc4b47049c72d155 Mon Sep 17 00:00:00 2001 From: Matt Lebl Date: Fri, 19 Mar 2021 02:16:07 -0700 Subject: [PATCH 151/282] feat: Replace emojis when NO_EMOJI env variable present --- src/exercise.rs | 7 ++++++- src/ui.rs | 44 ++++++++++++++++++++++++++++++++++---------- src/verify.rs | 15 +++++++++++++-- 3 files changed, 53 insertions(+), 13 deletions(-) diff --git a/src/exercise.rs b/src/exercise.rs index 18e8d5ab..2c5d835e 100644 --- a/src/exercise.rs +++ b/src/exercise.rs @@ -1,3 +1,4 @@ +use std::env; use regex::Regex; use serde::Deserialize; use std::fmt::{self, Display, Formatter}; @@ -126,8 +127,12 @@ name = "{}" path = "{}.rs""#, self.name, self.name, self.name ); + let cargo_toml_error_msg = match env::var("NO_EMOJI").is_ok() { + true => "Failed to write Clippy Cargo.toml file.", + false => "Failed to write πŸ“Ž Clippy πŸ“Ž Cargo.toml file." + }; fs::write(CLIPPY_CARGO_TOML_PATH, cargo_toml) - .expect("Failed to write πŸ“Ž Clippy πŸ“Ž Cargo.toml file."); + .expect(cargo_toml_error_msg); // To support the ability to run the clipy exercises, build // an executable, in addition to running clippy. With a // compilation failure, this would silently fail. But we expect diff --git a/src/ui.rs b/src/ui.rs index 38cbaa40..7ab87546 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -1,23 +1,47 @@ macro_rules! warn { ($fmt:literal, $ex:expr) => {{ + use std::env; use console::{style, Emoji}; let formatstr = format!($fmt, $ex); - println!( - "{} {}", - style(Emoji("⚠️ ", "!")).red(), - style(formatstr).red() - ); + match env::var("NO_EMOJI").is_ok() { + true => { + println!( + "{} {}", + style("!").red(), + style(formatstr).red() + ); + }, + false => { + println!( + "{} {}", + style(Emoji("⚠️ ", "!")).red(), + style(formatstr).red() + ); + } + } }}; } macro_rules! success { ($fmt:literal, $ex:expr) => {{ + use std::env; use console::{style, Emoji}; let formatstr = format!($fmt, $ex); - println!( - "{} {}", - style(Emoji("βœ…", "βœ“")).green(), - style(formatstr).green() - ); + match env::var("NO_EMOJI").is_ok() { + true => { + println!( + "{} {}", + style("βœ“").green(), + style(formatstr).green() + ); + }, + false => { + println!( + "{} {}", + style(Emoji("βœ…", "βœ“")).green(), + style(formatstr).green() + ); + } + } }}; } diff --git a/src/verify.rs b/src/verify.rs index 00e45c8c..04acfc68 100644 --- a/src/verify.rs +++ b/src/verify.rs @@ -1,3 +1,4 @@ +use std::env; use crate::exercise::{CompiledExercise, Exercise, Mode, State}; use console::style; use indicatif::ProgressBar; @@ -137,14 +138,24 @@ fn prompt_for_completion(exercise: &Exercise, prompt_output: Option) -> State::Pending(context) => context, }; + let no_emoji = env::var("NO_EMOJI").is_ok(); + + let clippy_success_msg = match no_emoji { + true => "The code is compiling, and Clippy is happy!", + false => "The code is compiling, and πŸ“Ž Clippy πŸ“Ž is happy!" + }; + let success_msg = match exercise.mode { Mode::Compile => "The code is compiling!", Mode::Test => "The code is compiling, and the tests pass!", - Mode::Clippy => "The code is compiling, and πŸ“Ž Clippy πŸ“Ž is happy!", + Mode::Clippy => clippy_success_msg, }; println!(); - println!("πŸŽ‰ πŸŽ‰ {} πŸŽ‰ πŸŽ‰", success_msg); + match no_emoji { + true => println!("~*~ {} ~*~", success_msg), + false => println!("πŸŽ‰ πŸŽ‰ {} πŸŽ‰ πŸŽ‰", success_msg) + }; println!(); if let Some(output) = prompt_output { From 01e7f27aa6ab9ba868f3997c1e5f5d3aa0bac57a Mon Sep 17 00:00:00 2001 From: Matt Lebl Date: Sat, 20 Mar 2021 11:52:57 -0700 Subject: [PATCH 152/282] refactor: change from match to if for NO_EMOJI --- src/exercise.rs | 7 ++++--- src/ui.rs | 54 ++++++++++++++++++++++--------------------------- src/verify.rs | 16 ++++++++------- 3 files changed, 37 insertions(+), 40 deletions(-) diff --git a/src/exercise.rs b/src/exercise.rs index 2c5d835e..3d2e38d1 100644 --- a/src/exercise.rs +++ b/src/exercise.rs @@ -127,9 +127,10 @@ name = "{}" path = "{}.rs""#, self.name, self.name, self.name ); - let cargo_toml_error_msg = match env::var("NO_EMOJI").is_ok() { - true => "Failed to write Clippy Cargo.toml file.", - false => "Failed to write πŸ“Ž Clippy πŸ“Ž Cargo.toml file." + let cargo_toml_error_msg = if env::var("NO_EMOJI").is_ok() { + "Failed to write Clippy Cargo.toml file." + } else { + "Failed to write πŸ“Ž Clippy πŸ“Ž Cargo.toml file." }; fs::write(CLIPPY_CARGO_TOML_PATH, cargo_toml) .expect(cargo_toml_error_msg); diff --git a/src/ui.rs b/src/ui.rs index 7ab87546..cb073372 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -3,21 +3,18 @@ macro_rules! warn { use std::env; use console::{style, Emoji}; let formatstr = format!($fmt, $ex); - match env::var("NO_EMOJI").is_ok() { - true => { - println!( - "{} {}", - style("!").red(), - style(formatstr).red() - ); - }, - false => { - println!( - "{} {}", - style(Emoji("⚠️ ", "!")).red(), - style(formatstr).red() - ); - } + if env::var("NO_EMOJI").is_ok() { + println!( + "{} {}", + style("!").red(), + style(formatstr).red() + ); + } else { + println!( + "{} {}", + style(Emoji("⚠️ ", "!")).red(), + style(formatstr).red() + ); } }}; } @@ -27,21 +24,18 @@ macro_rules! success { use std::env; use console::{style, Emoji}; let formatstr = format!($fmt, $ex); - match env::var("NO_EMOJI").is_ok() { - true => { - println!( - "{} {}", - style("βœ“").green(), - style(formatstr).green() - ); - }, - false => { - println!( - "{} {}", - style(Emoji("βœ…", "βœ“")).green(), - style(formatstr).green() - ); - } + if env::var("NO_EMOJI").is_ok() { + println!( + "{} {}", + style("βœ“").green(), + style(formatstr).green() + ); + } else { + println!( + "{} {}", + style(Emoji("βœ…", "βœ“")).green(), + style(formatstr).green() + ); } }}; } diff --git a/src/verify.rs b/src/verify.rs index 04acfc68..7a0e9ccd 100644 --- a/src/verify.rs +++ b/src/verify.rs @@ -140,9 +140,10 @@ fn prompt_for_completion(exercise: &Exercise, prompt_output: Option) -> let no_emoji = env::var("NO_EMOJI").is_ok(); - let clippy_success_msg = match no_emoji { - true => "The code is compiling, and Clippy is happy!", - false => "The code is compiling, and πŸ“Ž Clippy πŸ“Ž is happy!" + let clippy_success_msg = if no_emoji { + "The code is compiling, and Clippy is happy!" + } else { + "The code is compiling, and πŸ“Ž Clippy πŸ“Ž is happy!" }; let success_msg = match exercise.mode { @@ -152,10 +153,11 @@ fn prompt_for_completion(exercise: &Exercise, prompt_output: Option) -> }; println!(); - match no_emoji { - true => println!("~*~ {} ~*~", success_msg), - false => println!("πŸŽ‰ πŸŽ‰ {} πŸŽ‰ πŸŽ‰", success_msg) - }; + if no_emoji { + println!("~*~ {} ~*~", success_msg) + } else { + println!("πŸŽ‰ πŸŽ‰ {} πŸŽ‰ πŸŽ‰", success_msg) + } println!(); if let Some(output) = prompt_output { From 3df094713f4546745d4a9ea75cd75cba62473067 Mon Sep 17 00:00:00 2001 From: Rod Elias Date: Sat, 20 Mar 2021 17:12:49 -0300 Subject: [PATCH 153/282] chore: capitalize `c` letter By capitalizing the `c` letter it makes clear that we're talking about the C programming language. --- exercises/structs/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/structs/README.md b/exercises/structs/README.md index d2d7dc24..72e0061b 100644 --- a/exercises/structs/README.md +++ b/exercises/structs/README.md @@ -1,6 +1,6 @@ ### Structs -Rust has three struct types: a classic c struct, a tuple struct, and a unit struct. +Rust has three struct types: a classic C struct, a tuple struct, and a unit struct. #### Book Sections From 550c4293ed269a7d888c384076ba247662af58c3 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Sat, 20 Mar 2021 21:13:35 +0100 Subject: [PATCH 154/282] docs: add chapeupreto as a contributor (#678) * docs: update README.md [skip ci] * docs: update .all-contributorsrc [skip ci] Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com> --- .all-contributorsrc | 9 +++++++++ README.md | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index 5239b29c..ccce9476 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -756,6 +756,15 @@ "contributions": [ "content" ] + }, + { + "login": "chapeupreto", + "name": "Rod Elias", + "avatar_url": "https://avatars.githubusercontent.com/u/834048?v=4", + "profile": "https://twitter.com/chapeupreto", + "contributions": [ + "content" + ] } ], "contributorsPerLine": 8, diff --git a/README.md b/README.md index 85bba46d..995b4258 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -[![All Contributors](https://img.shields.io/badge/all_contributors-81-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-82-orange.svg?style=flat-square)](#contributors-) # rustlings πŸ¦€β€οΈ @@ -262,6 +262,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Pascal H.

πŸ–‹ +
Rod Elias

πŸ–‹ From 8dc587b01ab2e49a06308de29541330ff83dc371 Mon Sep 17 00:00:00 2001 From: marisa Date: Sun, 21 Mar 2021 16:34:21 +0100 Subject: [PATCH 155/282] chore: Update install URLs --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 995b4258..5871e3dc 100644 --- a/README.md +++ b/README.md @@ -24,9 +24,9 @@ You will need to have Rust installed. You can get it by visiting https://rustup. Just run: ```bash -curl -L https://git.io/rustlings | bash +curl -L https://git.io/install-rustlings | bash # Or if you want it to be installed to a different path: -curl -L https://git.io/rustlings | bash -s mypath/ +curl -L https://git.io/install-rustlings | bash -s mypath/ ``` This will install Rustlings and give you access to the `rustlings` command. Run it to get started! @@ -42,7 +42,7 @@ Set-ExecutionPolicy RemoteSigned Then, you can run: ```ps -Start-BitsTransfer -Source https://git.io/rustlings-win -Destination $env:TMP/install_rustlings.ps1; Unblock-File $env:TMP/install_rustlings.ps1; Invoke-Expression $env:TMP/install_rustlings.ps1 +Start-BitsTransfer -Source https://git.io/install-rustlings-win -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. From c163011cc0e3b0d9eaae7ae51aadba1cf9a2226e Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Mon, 22 Mar 2021 12:37:01 +0000 Subject: [PATCH 156/282] docs: update README.md [skip ci] --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5871e3dc..75e298fb 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -[![All Contributors](https://img.shields.io/badge/all_contributors-82-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-83-orange.svg?style=flat-square)](#contributors-) # rustlings πŸ¦€β€οΈ @@ -263,6 +263,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Pascal H.

πŸ–‹
Rod Elias

πŸ–‹ +
Matt Lebl

πŸ’» From 2a6e4dc8a65a1658f55edc5fe63854197839b358 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Mon, 22 Mar 2021 12:37:02 +0000 Subject: [PATCH 157/282] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index ccce9476..4726b643 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -765,6 +765,15 @@ "contributions": [ "content" ] + }, + { + "login": "blerchy", + "name": "Matt Lebl", + "avatar_url": "https://avatars.githubusercontent.com/u/2555355?v=4", + "profile": "https://github.com/blerchy", + "contributions": [ + "code" + ] } ], "contributorsPerLine": 8, From a02b27975018f69c51147f5f8d9638a5f4e26811 Mon Sep 17 00:00:00 2001 From: marisa Date: Tue, 23 Mar 2021 09:10:40 +0100 Subject: [PATCH 158/282] chore: Provide a working Windows installation link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 75e298fb..b453bf41 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ Set-ExecutionPolicy RemoteSigned Then, you can run: ```ps -Start-BitsTransfer -Source https://git.io/install-rustlings-win -Destination $env:TMP/install_rustlings.ps1; Unblock-File $env:TMP/install_rustlings.ps1; Invoke-Expression $env:TMP/install_rustlings.ps1 +Start-BitsTransfer -Source https://git.io/JTL5v -Destination $env:TMP/install_rustlings.ps1; Unblock-File $env:TMP/install_rustlings.ps1; Invoke-Expression $env:TMP/install_rustlings.ps1 ``` To install Rustlings. Same as on MacOS/Linux, you will have access to the `rustlings` command after it. From a6509cc4d545d8825f01ddf7ee37823b372154dd Mon Sep 17 00:00:00 2001 From: Ignacio Le Fluk Date: Sun, 4 Apr 2021 03:43:25 -0400 Subject: [PATCH 159/282] fix(functions3): improve function argument type (#687) --- exercises/functions/functions3.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/functions/functions3.rs b/exercises/functions/functions3.rs index e3c1bf73..ed5f839f 100644 --- a/exercises/functions/functions3.rs +++ b/exercises/functions/functions3.rs @@ -7,7 +7,7 @@ fn main() { call_me(); } -fn call_me(num: i32) { +fn call_me(num: u32) { for i in 0..num { println!("Ring! Call number {}", i + 1); } From aec2c65c632c94793d23fbb1fb826dd78e59ffdf Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Sun, 4 Apr 2021 07:43:50 +0000 Subject: [PATCH 160/282] docs: update README.md [skip ci] --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b453bf41..479a307c 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -[![All Contributors](https://img.shields.io/badge/all_contributors-83-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-84-orange.svg?style=flat-square)](#contributors-) # rustlings πŸ¦€β€οΈ @@ -264,6 +264,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Pascal H.

πŸ–‹
Rod Elias

πŸ–‹
Matt Lebl

πŸ’» +
Ignacio Le Fluk

πŸ–‹ From 2193fff4bb5e6becee03b1e9c37ee5069e6c9138 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Sun, 4 Apr 2021 07:43:51 +0000 Subject: [PATCH 161/282] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 4726b643..b0975cfe 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -774,6 +774,15 @@ "contributions": [ "code" ] + }, + { + "login": "flakolefluk", + "name": "Ignacio Le Fluk", + "avatar_url": "https://avatars.githubusercontent.com/u/11986564?v=4", + "profile": "http://flakolefluk.dev", + "contributions": [ + "content" + ] } ], "contributorsPerLine": 8, From 2e93a588e0abe8badb7eafafb9e7d073c2be5df8 Mon Sep 17 00:00:00 2001 From: Taylor Yu Date: Sun, 4 Apr 2021 00:04:03 -0500 Subject: [PATCH 162/282] fix: use trait objects for try_from_into Use `Box` to allow solutions to use `?` to propagate errors. In the tests, explicitly check `is_ok()` instead of trying to force the error type to `String` (or other `PartialEq` type) using `assert_eq!()`. --- exercises/conversions/try_from_into.rs | 40 ++++++++++++++------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/exercises/conversions/try_from_into.rs b/exercises/conversions/try_from_into.rs index e405c3f4..c0b5d986 100644 --- a/exercises/conversions/try_from_into.rs +++ b/exercises/conversions/try_from_into.rs @@ -3,6 +3,7 @@ // instead of the target type itself. // You can read more about it at https://doc.rust-lang.org/std/convert/trait.TryFrom.html use std::convert::{TryFrom, TryInto}; +use std::error; #[derive(Debug, PartialEq)] struct Color { @@ -24,19 +25,19 @@ struct Color { // Tuple implementation impl TryFrom<(i16, i16, i16)> for Color { - type Error = String; + type Error = Box; fn try_from(tuple: (i16, i16, i16)) -> Result {} } // Array implementation impl TryFrom<[i16; 3]> for Color { - type Error = String; + type Error = Box; fn try_from(arr: [i16; 3]) -> Result {} } // Slice implementation impl TryFrom<&[i16]> for Color { - type Error = String; + type Error = Box; fn try_from(slice: &[i16]) -> Result {} } @@ -76,41 +77,43 @@ mod tests { } #[test] fn test_tuple_correct() { - let c: Result = (183, 65, 14).try_into(); + let c: Result = (183, 65, 14).try_into(); + assert!(c.is_ok()); assert_eq!( - c, - Ok(Color { + c.unwrap(), + Color { red: 183, green: 65, blue: 14 - }) + } ); } #[test] fn test_array_out_of_range_positive() { - let c: Result = [1000, 10000, 256].try_into(); + let c: Result = [1000, 10000, 256].try_into(); assert!(c.is_err()); } #[test] fn test_array_out_of_range_negative() { - let c: Result = [-10, -256, -1].try_into(); + let c: Result = [-10, -256, -1].try_into(); assert!(c.is_err()); } #[test] fn test_array_sum() { - let c: Result = [-1, 255, 255].try_into(); + let c: Result = [-1, 255, 255].try_into(); assert!(c.is_err()); } #[test] fn test_array_correct() { - let c: Result = [183, 65, 14].try_into(); + let c: Result = [183, 65, 14].try_into(); + assert!(c.is_ok()); assert_eq!( - c, - Ok(Color { + c.unwrap(), + Color { red: 183, green: 65, blue: 14 - }) + } ); } #[test] @@ -131,14 +134,15 @@ mod tests { #[test] fn test_slice_correct() { let v = vec![183, 65, 14]; - let c: Result = Color::try_from(&v[..]); + let c: Result = Color::try_from(&v[..]); + assert!(c.is_ok()); assert_eq!( - c, - Ok(Color { + c.unwrap(), + Color { red: 183, green: 65, blue: 14 - }) + } ); } #[test] From c3e7b831786c9172ed8bd5d150f3c432f242fba9 Mon Sep 17 00:00:00 2001 From: Taylor Yu Date: Sun, 4 Apr 2021 18:43:38 -0500 Subject: [PATCH 163/282] fix: use trait objects for from_str Use `Box` to allow solutions to use `?` to propagate errors. --- exercises/conversions/from_str.rs | 3 ++- info.toml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/exercises/conversions/from_str.rs b/exercises/conversions/from_str.rs index 41fccd7e..4beebacd 100644 --- a/exercises/conversions/from_str.rs +++ b/exercises/conversions/from_str.rs @@ -2,6 +2,7 @@ // Additionally, upon implementing FromStr, you can use the `parse` method // on strings to generate an object of the implementor type. // You can read more about it at https://doc.rust-lang.org/std/str/trait.FromStr.html +use std::error; use std::str::FromStr; #[derive(Debug)] @@ -23,7 +24,7 @@ struct Person { // If everything goes well, then return a Result of a Person object impl FromStr for Person { - type Err = String; + type Err = Box; fn from_str(s: &str) -> Result { } } diff --git a/info.toml b/info.toml index 2068750a..4a1d3aa3 100644 --- a/info.toml +++ b/info.toml @@ -884,5 +884,5 @@ 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 a string if the string is not valid. +or an Err with an error if the string is not valid. This is almost like the `try_from_into` exercise.""" From 1ad20d94ff6982e66561d03727e52f04ffa8756b Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Mon, 5 Apr 2021 11:27:16 +0000 Subject: [PATCH 164/282] docs: update README.md [skip ci] --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 479a307c..6ffef489 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -[![All Contributors](https://img.shields.io/badge/all_contributors-84-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-85-orange.svg?style=flat-square)](#contributors-) # rustlings πŸ¦€β€οΈ @@ -265,6 +265,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Rod Elias

πŸ–‹
Matt Lebl

πŸ’»
Ignacio Le Fluk

πŸ–‹ +
Taylor Yu

πŸ’» πŸ–‹ From 1a6a725f882ac25b4ed12cd960fdc3aad9b80eb3 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Mon, 5 Apr 2021 11:27:17 +0000 Subject: [PATCH 165/282] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index b0975cfe..c7f10be4 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -783,6 +783,16 @@ "contributions": [ "content" ] + }, + { + "login": "tlyu", + "name": "Taylor Yu", + "avatar_url": "https://avatars.githubusercontent.com/u/431873?v=4", + "profile": "https://github.com/tlyu", + "contributions": [ + "code", + "content" + ] } ], "contributorsPerLine": 8, From b790bafc02b6cbeab928a5ddeba30ed8b111a817 Mon Sep 17 00:00:00 2001 From: WowSuchRicky Date: Fri, 9 Apr 2021 14:08:02 -0700 Subject: [PATCH 166/282] Rename lichi to lychee in the fruit example --- exercises/collections/hashmap2.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/exercises/collections/hashmap2.rs b/exercises/collections/hashmap2.rs index 7e25be7c..cacdf203 100644 --- a/exercises/collections/hashmap2.rs +++ b/exercises/collections/hashmap2.rs @@ -4,7 +4,7 @@ // represents the name of the fruit and the value represents how many // of that particular fruit is in the basket. You have to put *MORE // THAN 11* fruits in the basket. Three types of fruits - Apple (4), -// Mango (2) and Lichi (5) are already given in the basket. You are +// Mango (2) and Lychee (5) are already given in the basket. You are // not allowed to insert any more of these fruits! // // Make me pass the tests! @@ -21,7 +21,7 @@ enum Fruit { Apple, Banana, Mango, - Lichi, + Lychee, Pineapple, } @@ -30,7 +30,7 @@ fn fruit_basket(basket: &mut HashMap) { Fruit::Apple, Fruit::Banana, Fruit::Mango, - Fruit::Lichi, + Fruit::Lychee, Fruit::Pineapple, ]; @@ -49,7 +49,7 @@ mod tests { let mut basket = HashMap::::new(); basket.insert(Fruit::Apple, 4); basket.insert(Fruit::Mango, 2); - basket.insert(Fruit::Lichi, 5); + basket.insert(Fruit::Lychee, 5); basket } @@ -60,7 +60,7 @@ mod tests { fruit_basket(&mut basket); assert_eq!(*basket.get(&Fruit::Apple).unwrap(), 4); assert_eq!(*basket.get(&Fruit::Mango).unwrap(), 2); - assert_eq!(*basket.get(&Fruit::Lichi).unwrap(), 5); + assert_eq!(*basket.get(&Fruit::Lychee).unwrap(), 5); } #[test] From c0e3daacaf6850811df5bc57fa43e0f249d5cfa4 Mon Sep 17 00:00:00 2001 From: Zerotask Date: Sun, 18 Apr 2021 15:37:41 +0200 Subject: [PATCH 167/282] feat(list): added progress info Added a progress info at the bottom of the list for command: rustlings list closes #705 --- src/main.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 569aa4ac..73647234 100644 --- a/src/main.rs +++ b/src/main.rs @@ -138,13 +138,19 @@ fn main() { println!("{:<17}\t{:<46}\t{:<7}", "Name", "Path", "Status"); } let filters = list_m.value_of("filter").unwrap_or_default().to_lowercase(); + let mut exercises_done: u16 = 0; exercises.iter().for_each(|e| { let fname = format!("{}", e.path.display()); let filter_cond = filters .split(',') .filter(|f| !f.trim().is_empty()) .any(|f| e.name.contains(&f) || fname.contains(&f)); - let status = if e.looks_done() { "Done" } else { "Pending" }; + let status = if e.looks_done() { + exercises_done = exercises_done + 1; + "Done" + } else { + "Pending" + }; let solve_cond = { (e.looks_done() && list_m.is_present("solved")) || (!e.looks_done() && list_m.is_present("unsolved")) @@ -173,6 +179,13 @@ fn main() { } } }); + let percentage_progress = exercises_done as f32 / exercises.len() as f32; + println!( + "Progress: You completed {} / {} exercises ({:.2} %).", + exercises_done, + exercises.len(), + percentage_progress + ); std::process::exit(0); } @@ -314,7 +327,7 @@ fn watch(exercises: &[Exercise], verbose: bool) -> notify::Result<()> { .chain( exercises .iter() - .filter(|e| !e.looks_done() && !filepath.ends_with(&e.path)) + .filter(|e| !e.looks_done() && !filepath.ends_with(&e.path)), ); clear_screen(); match verify(pending_exercises, verbose) { From bd48544e25bb58f86fee1b1a5004e961996a3388 Mon Sep 17 00:00:00 2001 From: Zerotask Date: Sun, 18 Apr 2021 15:40:47 +0200 Subject: [PATCH 168/282] style: formatted files with rustfmt --- src/exercise.rs | 5 ++--- src/ui.rs | 16 ++++------------ src/verify.rs | 2 +- 3 files changed, 7 insertions(+), 16 deletions(-) diff --git a/src/exercise.rs b/src/exercise.rs index 3d2e38d1..e9d1c1c9 100644 --- a/src/exercise.rs +++ b/src/exercise.rs @@ -1,6 +1,6 @@ -use std::env; use regex::Regex; use serde::Deserialize; +use std::env; use std::fmt::{self, Display, Formatter}; use std::fs::{self, remove_file, File}; use std::io::Read; @@ -132,8 +132,7 @@ path = "{}.rs""#, } else { "Failed to write πŸ“Ž Clippy πŸ“Ž Cargo.toml file." }; - fs::write(CLIPPY_CARGO_TOML_PATH, cargo_toml) - .expect(cargo_toml_error_msg); + fs::write(CLIPPY_CARGO_TOML_PATH, cargo_toml).expect(cargo_toml_error_msg); // To support the ability to run the clipy exercises, build // an executable, in addition to running clippy. With a // compilation failure, this would silently fail. But we expect diff --git a/src/ui.rs b/src/ui.rs index cb073372..1ee46316 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -1,14 +1,10 @@ macro_rules! warn { ($fmt:literal, $ex:expr) => {{ - use std::env; use console::{style, Emoji}; + use std::env; let formatstr = format!($fmt, $ex); if env::var("NO_EMOJI").is_ok() { - println!( - "{} {}", - style("!").red(), - style(formatstr).red() - ); + println!("{} {}", style("!").red(), style(formatstr).red()); } else { println!( "{} {}", @@ -21,15 +17,11 @@ macro_rules! warn { macro_rules! success { ($fmt:literal, $ex:expr) => {{ - use std::env; use console::{style, Emoji}; + use std::env; let formatstr = format!($fmt, $ex); if env::var("NO_EMOJI").is_ok() { - println!( - "{} {}", - style("βœ“").green(), - style(formatstr).green() - ); + println!("{} {}", style("βœ“").green(), style(formatstr).green()); } else { println!( "{} {}", diff --git a/src/verify.rs b/src/verify.rs index 7a0e9ccd..b98598a8 100644 --- a/src/verify.rs +++ b/src/verify.rs @@ -1,7 +1,7 @@ -use std::env; use crate::exercise::{CompiledExercise, Exercise, Mode, State}; use console::style; use indicatif::ProgressBar; +use std::env; // Verify that the provided container of Exercise objects // can be compiled and run without any failures. From e2c41903ad491df5c0c59c389e3f568dd2485611 Mon Sep 17 00:00:00 2001 From: Zerotask Date: Sun, 18 Apr 2021 16:07:30 +0200 Subject: [PATCH 169/282] docs: added hint for rustlings list command Added hint for `rustlings list` to the "Doing exercises" section. --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 6ffef489..19ec6ce4 100644 --- a/README.md +++ b/README.md @@ -104,6 +104,11 @@ exercise: rustlings hint myExercise1 ``` +To check your progress, you can run the following command: +```bash +rustlings list +``` + ## Testing yourself After every couple of sections, there will be a quiz that'll test your knowledge on a bunch of sections at once. These quizzes are found in `exercises/quizN.rs`. From 1c6f7e4b7b9b3bd36f4da2bb2b69c549cc8bd913 Mon Sep 17 00:00:00 2001 From: Patrick Hintermayer Date: Mon, 19 Apr 2021 09:39:05 +0200 Subject: [PATCH 170/282] feat(list): updated progress percentage --- src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 73647234..3b7a1942 100644 --- a/src/main.rs +++ b/src/main.rs @@ -179,7 +179,7 @@ fn main() { } } }); - let percentage_progress = exercises_done as f32 / exercises.len() as f32; + let percentage_progress = exercises_done as f32 / exercises.len() as f32 * 100.0; println!( "Progress: You completed {} / {} exercises ({:.2} %).", exercises_done, From 2612edc133c8ec6e2c10c13ed9c86019ea6d27d9 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Tue, 20 Apr 2021 09:09:30 +0000 Subject: [PATCH 171/282] docs: update README.md [skip ci] --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6ffef489..ed0095cf 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -[![All Contributors](https://img.shields.io/badge/all_contributors-85-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-86-orange.svg?style=flat-square)](#contributors-) # rustlings πŸ¦€β€οΈ @@ -266,6 +266,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Matt Lebl

πŸ’»
Ignacio Le Fluk

πŸ–‹
Taylor Yu

πŸ’» πŸ–‹ +
Patrick Hintermayer

πŸ’» From 63c942233e8e9fe1171e51acf35d8dc93897471b Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Tue, 20 Apr 2021 09:09:31 +0000 Subject: [PATCH 172/282] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index c7f10be4..8621df10 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -793,6 +793,15 @@ "code", "content" ] + }, + { + "login": "Zerotask", + "name": "Patrick Hintermayer", + "avatar_url": "https://avatars.githubusercontent.com/u/20150243?v=4", + "profile": "https://zerotask.github.io", + "contributions": [ + "code" + ] } ], "contributorsPerLine": 8, From 72aaa15e6ab4b72b3422f1c6356396e20a2a2bb8 Mon Sep 17 00:00:00 2001 From: Pete Pavlovski Date: Tue, 20 Apr 2021 12:15:49 +0300 Subject: [PATCH 173/282] fix(hashmap2): Update incorrect assertion (#660) The test description says "at least five types of fruit", but the test itself is checking for exactly five types of fruit, which was a bit misleading for newcomers like me :) A simple change from "==" to ">=" should do the trick and successfully check for the "at least" condition. --- exercises/collections/hashmap2.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/collections/hashmap2.rs b/exercises/collections/hashmap2.rs index c8698fed..0abe19ab 100644 --- a/exercises/collections/hashmap2.rs +++ b/exercises/collections/hashmap2.rs @@ -68,7 +68,7 @@ mod tests { let mut basket = get_fruit_basket(); fruit_basket(&mut basket); let count_fruit_kinds = basket.len(); - assert!(count_fruit_kinds == 5); + assert!(count_fruit_kinds >= 5); } #[test] From a941c69f09c7349ff578da348a075a146c1005b6 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Tue, 20 Apr 2021 09:16:15 +0000 Subject: [PATCH 174/282] docs: update README.md [skip ci] --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 760565e2..10b7c1cf 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -[![All Contributors](https://img.shields.io/badge/all_contributors-86-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-87-orange.svg?style=flat-square)](#contributors-) # rustlings πŸ¦€β€οΈ @@ -272,6 +272,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Ignacio Le Fluk

πŸ–‹
Taylor Yu

πŸ’» πŸ–‹
Patrick Hintermayer

πŸ’» +
Pete Pavlovski

πŸ–‹ From bdf01aa174533d5908e83a7ed3113b62f4eb6fe3 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Tue, 20 Apr 2021 09:16:16 +0000 Subject: [PATCH 175/282] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 8621df10..0b490899 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -802,6 +802,15 @@ "contributions": [ "code" ] + }, + { + "login": "arthas168", + "name": "Pete Pavlovski", + "avatar_url": "https://avatars.githubusercontent.com/u/32264020?v=4", + "profile": "https://petkopavlovski.com/", + "contributions": [ + "content" + ] } ], "contributorsPerLine": 8, From b4de6594380636817d13c2677ec6f472a964cf43 Mon Sep 17 00:00:00 2001 From: k12ish <45272873+k12ish@users.noreply.github.com> Date: Tue, 20 Apr 2021 10:18:05 +0100 Subject: [PATCH 176/282] fix(option2): Rename uninformative variables (#675) Renaming uninformative names like `optional_value`, `value`, `optional_values_vec` and `value` helps users distinguish between the two parts of the task. --- exercises/option/option2.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/exercises/option/option2.rs b/exercises/option/option2.rs index a1517d7c..c6b83ece 100644 --- a/exercises/option/option2.rs +++ b/exercises/option/option2.rs @@ -4,22 +4,22 @@ // I AM NOT DONE fn main() { - let optional_value = Some(String::from("rustlings")); + let optional_word = Some(String::from("rustlings")); // TODO: Make this an if let statement whose value is "Some" type - value = optional_value { - println!("the value of optional value is: {}", value); + word = optional_word { + println!("The word is: {}", word); } else { - println!("The optional value doesn't contain anything!"); + println!("The optional word doesn't contain anything"); } - let mut optional_values_vec: Vec> = Vec::new(); + let mut optional_integers_vec: Vec> = Vec::new(); for x in 1..10 { - optional_values_vec.push(Some(x)); + optional_integers_vec.push(Some(x)); } // TODO: make this a while let statement - remember that vector.pop also adds another layer of Option // You can stack `Option`'s into while let and if let - value = optional_values_vec.pop() { - println!("current value: {}", value); + integer = optional_integers_vec.pop() { + println!("current value: {}", integer); } } From 472f61485e49864d62901ee024ed5c8a18b861a0 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Tue, 20 Apr 2021 09:18:22 +0000 Subject: [PATCH 177/282] docs: update README.md [skip ci] --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 10b7c1cf..721c63a0 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -[![All Contributors](https://img.shields.io/badge/all_contributors-87-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-88-orange.svg?style=flat-square)](#contributors-) # rustlings πŸ¦€β€οΈ @@ -273,6 +273,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Taylor Yu

πŸ’» πŸ–‹
Patrick Hintermayer

πŸ’»
Pete Pavlovski

πŸ–‹ +
k12ish

πŸ–‹ From 65cdc856aec4f86c7b513d2b85d3357e5a9b3a4f Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Tue, 20 Apr 2021 09:18:23 +0000 Subject: [PATCH 178/282] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 0b490899..a2473872 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -811,6 +811,15 @@ "contributions": [ "content" ] + }, + { + "login": "k12ish", + "name": "k12ish", + "avatar_url": "https://avatars.githubusercontent.com/u/45272873?v=4", + "profile": "https://github.com/k12ish", + "contributions": [ + "content" + ] } ], "contributorsPerLine": 8, From 6bd791f2f44aa7f0ad926df767f6b1fa8f12a9a9 Mon Sep 17 00:00:00 2001 From: Shao Yang Hong Date: Tue, 20 Apr 2021 17:19:24 +0800 Subject: [PATCH 179/282] fix(structs): Add 5.3 to structs/README (#652) Co-authored-by: Shao Yang Hong --- exercises/structs/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/exercises/structs/README.md b/exercises/structs/README.md index 72e0061b..58e5a6a4 100644 --- a/exercises/structs/README.md +++ b/exercises/structs/README.md @@ -5,3 +5,4 @@ Rust has three struct types: a classic C struct, a tuple struct, and a unit stru #### Book Sections - [Structures](https://doc.rust-lang.org/book/ch05-01-defining-structs.html) +- [Method Syntax](https://doc.rust-lang.org/book/ch05-03-method-syntax.html) From fab2eb98333434079a3ace6c7d0aa31892bd49cb Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Tue, 20 Apr 2021 09:19:38 +0000 Subject: [PATCH 180/282] docs: update README.md [skip ci] --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 721c63a0..2d2cb0ef 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -[![All Contributors](https://img.shields.io/badge/all_contributors-88-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-89-orange.svg?style=flat-square)](#contributors-) # rustlings πŸ¦€β€οΈ @@ -275,6 +275,9 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Pete Pavlovski

πŸ–‹
k12ish

πŸ–‹ + +
Shao Yang Hong

πŸ–‹ + From eadd41a9ecb05e3278a988f752e77608ded136fa Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Tue, 20 Apr 2021 09:19:39 +0000 Subject: [PATCH 181/282] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index a2473872..e820b426 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -820,6 +820,15 @@ "contributions": [ "content" ] + }, + { + "login": "hongshaoyang", + "name": "Shao Yang Hong", + "avatar_url": "https://avatars.githubusercontent.com/u/19281800?v=4", + "profile": "https://github.com/hongshaoyang", + "contributions": [ + "content" + ] } ], "contributorsPerLine": 8, From 9c88ea91266c84901fd46496902610241dab3baf Mon Sep 17 00:00:00 2001 From: apogeeoak <59737221+apogeeoak@users.noreply.github.com> Date: Tue, 20 Apr 2021 18:52:10 -0400 Subject: [PATCH 182/282] Improved iterators5.rs explanation. --- .../standard_library_types/iterators5.rs | 51 +++++++++++-------- info.toml | 11 ++-- 2 files changed, 37 insertions(+), 25 deletions(-) diff --git a/exercises/standard_library_types/iterators5.rs b/exercises/standard_library_types/iterators5.rs index 65c50e62..2d97bd46 100644 --- a/exercises/standard_library_types/iterators5.rs +++ b/exercises/standard_library_types/iterators5.rs @@ -1,11 +1,14 @@ // iterators5.rs -// Rustling progress is modelled using a hash map. The name of the exercise is -// the key and the progress is the value. Two counting functions were created -// to count the number of exercises with a given progress. These counting -// functions use imperative style for loops. Recreate this counting -// functionality using iterators. -// Execute `rustlings hint iterators5` for hints. +// Let's define a simple model to track Rustlings exercise progress. Progress +// will be modelled using a hash map. The name of the exercise is the key and +// the progress is the value. Two counting functions were created to count the +// number of exercises with a given progress. These counting functions use +// imperative style for loops. Recreate this counting functionality using +// iterators. Only the two iterator methods (count_iterator and +// count_collection_iterator) need to be modified. +// Execute `rustlings hint +// iterators5` for hints. // // Make the code compile and the tests pass. @@ -30,12 +33,14 @@ fn count_for(map: &HashMap, value: Progress) -> usize { count } -fn count(map: &HashMap, value: Progress) -> usize { +fn count_iterator(map: &HashMap, value: Progress) -> usize { + // map is a hashmap with String keys and Progress values. + // map = { "variables1": Complete, "from_str": None, ... } } -fn count_stack_for(stack: &[HashMap], value: Progress) -> usize { +fn count_collection_for(collection: &[HashMap], value: Progress) -> usize { let mut count = 0; - for map in stack { + for map in collection { for val in map.values() { if val == &value { count += 1; @@ -45,7 +50,10 @@ fn count_stack_for(stack: &[HashMap], value: Progress) -> usiz count } -fn count_stack(stack: &[HashMap], value: Progress) -> usize { +fn count_collection_iterator(collection: &[HashMap], value: Progress) -> usize { + // collection is a slice of hashmaps. + // collection = [{ "variables1": Complete, "from_str": None, ... }, + // { "variables2": Complete, ... }, ... ] } #[cfg(test)] @@ -55,7 +63,7 @@ mod tests { #[test] fn count_complete() { let map = get_map(); - assert_eq!(3, count(&map, Progress::Complete)); + assert_eq!(3, count_iterator(&map, Progress::Complete)); } #[test] @@ -63,22 +71,25 @@ mod tests { let map = get_map(); assert_eq!( count_for(&map, Progress::Complete), - count(&map, Progress::Complete) + count_iterator(&map, Progress::Complete) ); } #[test] - fn count_stack_complete() { - let stack = get_map_stack(); - assert_eq!(6, count_stack(&stack, Progress::Complete)); + fn count_collection_complete() { + let collection = get_vec_map(); + assert_eq!( + 6, + count_collection_iterator(&collection, Progress::Complete) + ); } #[test] - fn count_stack_equals_for() { - let stack = get_map_stack(); + fn count_collection_equals_for() { + let collection = get_vec_map(); assert_eq!( - count_stack_for(&stack, Progress::Complete), - count_stack(&stack, Progress::Complete) + count_collection_for(&collection, Progress::Complete), + count_collection_iterator(&collection, Progress::Complete) ); } @@ -96,7 +107,7 @@ mod tests { map } - fn get_map_stack() -> Vec> { + fn get_vec_map() -> Vec> { use Progress::*; let map = get_map(); diff --git a/info.toml b/info.toml index 646bb5a5..65f671ac 100644 --- a/info.toml +++ b/info.toml @@ -694,7 +694,7 @@ Step 2 & step 2.1: Very similar to the lines above and below. You've got this! Step 3: 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 +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. """ @@ -749,12 +749,13 @@ hint = """ The documentation for the std::iter::Iterator trait contains numerous methods that would be helpful here. -Return 0 from count_stack to make the code compile in order to test count. +Return 0 from count_collection_iterator to make the code compile in order to +test count_iterator. -The stack variable in count_stack 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 HashMaps. It +needs to be converted into an iterator in order to use the iterator methods. -The fold method can be useful in the count_stack function.""" +The fold method can be useful in the count_collection_iterator function.""" # THREADS From 7928122fcef9ca7834d988b1ec8ca0687478beeb Mon Sep 17 00:00:00 2001 From: mokou Date: Tue, 20 Apr 2021 12:46:49 +0200 Subject: [PATCH 183/282] feat: Replace clap with argh MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I’ve been wanting to do this for a while, but always procrastinated on it. We’ve been using Clap since the 2.0 rewrite, but Clap is known to be a fairly heavy library. Since Rustlings is usually peoples’ first contact with a Rust compilation, I think it’s in our best interests that this complation is as fast as possible. In effect, replacing Clap with the smaller, structopt-style `argh` reduces the amount of crates needing to be compiled from 82 to 60. I also think this makes the code way easier to read, we don’t need to use Clap’s methods anymore, but can switch over to using pure Rust methods, e.g., switches are booleans, options are Options or the like, and subcommands are just structs. --- Cargo.lock | 543 +++++++++++++++++------------------------------- Cargo.toml | 2 +- src/exercise.rs | 4 +- src/main.rs | 431 +++++++++++++++++++------------------- 4 files changed, 405 insertions(+), 575 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4a4313e7..367881c7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,22 +2,42 @@ # It is not intended for manual editing. [[package]] name = "aho-corasick" -version = "0.7.3" +version = "0.7.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6f484ae0c99fec2e858eb6134949117399f222608d84cadb3f58c1f97c2364c" +checksum = "7404febffaa47dac81aa44dba71523c9d069b1bdc50a77db41195149e17f68e5" dependencies = [ "memchr", ] [[package]] -name = "ansi_term" -version = "0.11.0" +name = "argh" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" +checksum = "91792f088f87cdc7a2cfb1d617fa5ea18d7f1dc22ef0e1b5f82f3157cdc522be" dependencies = [ - "winapi 0.3.8", + "argh_derive", + "argh_shared", ] +[[package]] +name = "argh_derive" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4eb0c0c120ad477412dc95a4ce31e38f2113e46bd13511253f79196ca68b067" +dependencies = [ + "argh_shared", + "heck", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "argh_shared" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "781f336cc9826dbaddb9754cb5db61e64cab4f69668bd19dcc4a0394a86f4cb1" + [[package]] name = "assert_cmd" version = "0.11.1" @@ -32,67 +52,49 @@ dependencies = [ [[package]] name = "atty" -version = "0.2.11" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" dependencies = [ + "hermit-abi", "libc", - "termion", - "winapi 0.3.8", + "winapi 0.3.9", ] [[package]] name = "autocfg" -version = "0.1.4" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e49efa51329a5fd37e7c79db4621af617cd4e3e5bc224939808d076077077bf" +checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" [[package]] name = "bitflags" -version = "1.0.4" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" +checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" [[package]] name = "cfg-if" -version = "0.1.9" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b486ce3ccf7ffd79fdeb678eac06a9e6c09fc88d33836340becb8fffe87c5e33" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" [[package]] -name = "clap" -version = "2.33.0" +name = "cfg-if" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" -dependencies = [ - "ansi_term", - "atty", - "bitflags", - "strsim", - "textwrap", - "unicode-width", - "vec_map", -] +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clicolors-control" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73abfd4c73d003a674ce5d2933fca6ce6c42480ea84a5ffe0a2dc39ed56300f9" +checksum = "90082ee5dcdd64dc4e9e0d37fbf3ee325419e39c0092191e0393df65518f741e" dependencies = [ "atty", "lazy_static", "libc", - "winapi 0.3.8", -] - -[[package]] -name = "cloudabi" -version = "0.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" -dependencies = [ - "bitflags", + "winapi 0.3.9", ] [[package]] @@ -110,23 +112,22 @@ dependencies = [ "regex", "termios", "unicode-width", - "winapi 0.3.8", + "winapi 0.3.9", ] [[package]] name = "console" -version = "0.8.0" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b147390a412132d75d10dd3b7b175a69cf5fd95032f7503c7091b8831ba10242" +checksum = "3993e6445baa160675931ec041a5e03ca84b9c6e32a056150d3aa2bdda0a1f45" dependencies = [ - "clicolors-control", "encode_unicode", "lazy_static", "libc", "regex", - "termios", + "terminal_size", "unicode-width", - "winapi 0.3.8", + "winapi 0.3.9", ] [[package]] @@ -137,9 +138,9 @@ checksum = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198" [[package]] name = "encode_unicode" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90b2c9496c001e8cb61827acdefad780795c42264c137744cae6f7d9e3450abd" +checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" [[package]] name = "escargot" @@ -155,20 +156,21 @@ dependencies = [ [[package]] name = "filetime" -version = "0.2.5" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f8c63033fcba1f51ef744505b3cad42510432b904c062afa67ad7ece008429d" +checksum = "1d34cfa13a63ae058bfa601fe9e313bbdb3746427c1459185464ce0fcf62e1e8" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", "libc", "redox_syscall", + "winapi 0.3.9", ] [[package]] name = "float-cmp" -version = "0.4.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "134a8fa843d80a51a5b77d36d42bc2def9edcb0262c914861d08129fd1926600" +checksum = "e1267f4ac4f343772758f7b1bdcbe767c218bbab93bb432acbf5162bbf85a6c4" dependencies = [ "num-traits", ] @@ -192,12 +194,6 @@ dependencies = [ "libc", ] -[[package]] -name = "fuchsia-cprng" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" - [[package]] name = "fuchsia-zircon" version = "0.3.3" @@ -220,13 +216,31 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" +[[package]] +name = "heck" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cbf45460356b7deeb5e3415b5563308c0a9b057c85e12b06ad551f98d0a6ac" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "hermit-abi" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "322f4de77956e22ed0e5032c359a0f1273f1f7f0d79bfa3b8ffbc730d7fbcc5c" +dependencies = [ + "libc", +] + [[package]] name = "indicatif" version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "40ecd1e2ee08e6c255ce890f5a99d17000850e664e7acf119fb03b25b0575bfe" dependencies = [ - "console 0.8.0", + "console 0.14.1", "lazy_static", "number_prefix", "parking_lot", @@ -235,9 +249,9 @@ dependencies = [ [[package]] name = "inotify" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24e40d6fd5d64e2082e0c796495c8ef5ad667a96d03e5aaa0becfd9d47bcbfb8" +checksum = "4816c66d2c8ae673df83366c18341538f234a26d65a9ecea5c348b453ac1d02f" dependencies = [ "bitflags", "inotify-sys", @@ -246,28 +260,36 @@ dependencies = [ [[package]] name = "inotify-sys" -version = "0.1.3" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e74a1aa87c59aeff6ef2cc2fa62d41bc43f54952f55652656b18a02fd5e356c0" +checksum = "e05c02b5e89bff3b946cedeca278abc628fe811e604f027c45a8aa3cf793d0eb" dependencies = [ "libc", ] +[[package]] +name = "instant" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61124eeebbd69b8190558df225adf7e4caafce0d743919e5d6b19652314ec5ec" +dependencies = [ + "cfg-if 1.0.0", +] + [[package]] name = "iovec" -version = "0.1.2" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08" +checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" dependencies = [ "libc", - "winapi 0.2.8", ] [[package]] name = "itoa" -version = "0.4.4" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" +checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" [[package]] name = "kernel32-sys" @@ -281,52 +303,53 @@ dependencies = [ [[package]] name = "lazy_static" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "lazycell" -version = "1.2.1" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f" +checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.58" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6281b86796ba5e4366000be6e9e18bf35580adf9e63fbe2294aadb587613a319" +checksum = "9385f66bf6105b241aa65a61cb923ef20efc665cb9f9bb50ac2f0c4b7f378d41" [[package]] name = "lock_api" -version = "0.2.0" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed946d4529956a20f2d63ebe1b69996d5a2137c91913fe3ebbeff957f5bca7ff" +checksum = "5a3c91c24eae6777794bb1997ad98bbb87daf92890acab859f7eaa4320333176" dependencies = [ "scopeguard", ] [[package]] name = "log" -version = "0.4.6" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c84ec4b527950aa83a329754b01dbe3f58361d1c5efacd1f6d68c494d08a17c6" +checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" dependencies = [ - "cfg-if", + "cfg-if 1.0.0", ] [[package]] name = "memchr" -version = "2.2.0" +version = "2.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2efc7bc57c883d4a4d6e3246905283d8dae951bb3bd32f49d6ef297f546e1c39" +checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" [[package]] name = "mio" -version = "0.6.19" +version = "0.6.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83f51996a3ed004ef184e16818edc51fadffe8e7ca68be67f9dee67d84d0ff23" +checksum = "4afd66f5b91bf2a3bc13fad0e21caedac168ca4c707504e75585648ae80e4cc4" dependencies = [ + "cfg-if 0.1.10", "fuchsia-zircon", "fuchsia-zircon-sys", "iovec", @@ -341,9 +364,9 @@ dependencies = [ [[package]] name = "mio-extras" -version = "2.0.5" +version = "2.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46e73a04c2fa6250b8d802134d56d554a9ec2922bf977777c805ea5def61ce40" +checksum = "52403fe290012ce777c4626790c8951324a2b9e3316b3143779c72b029742f19" dependencies = [ "lazycell", "log", @@ -353,9 +376,9 @@ dependencies = [ [[package]] name = "miow" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" +checksum = "ebd808424166322d4a38da87083bfddd3ac4c131334ed55856112eb06d46944d" dependencies = [ "kernel32-sys", "net2", @@ -365,26 +388,26 @@ dependencies = [ [[package]] name = "net2" -version = "0.2.33" +version = "0.2.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88" +checksum = "391630d12b68002ae1e25e8f974306474966550ad82dac6886fb8910c19568ae" dependencies = [ - "cfg-if", + "cfg-if 0.1.10", "libc", - "winapi 0.3.8", + "winapi 0.3.9", ] [[package]] name = "normalize-line-endings" -version = "0.2.2" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e0a1a39eab95caf4f5556da9289b9e68f0aafac901b2ce80daaf020d3b733a8" +checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be" [[package]] name = "notify" -version = "4.0.15" +version = "4.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80ae4a7688d1fab81c5bf19c64fc8db920be8d519ce6336ed4e7efe024724dbd" +checksum = "2599080e87c9bd051ddb11b10074f4da7b1223298df65d4c2ec5bcf309af1533" dependencies = [ "bitflags", "filetime", @@ -395,14 +418,14 @@ dependencies = [ "mio", "mio-extras", "walkdir", - "winapi 0.3.8", + "winapi 0.3.9", ] [[package]] name = "num-traits" -version = "0.2.8" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ba9a427cfca2be13aa6f6403b0b7e7368fe982bfa16fccc450ce74c46cd9b32" +checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" dependencies = [ "autocfg", ] @@ -416,44 +439,36 @@ dependencies = [ "num-traits", ] -[[package]] -name = "numtoa" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8f8bdf33df195859076e54ab11ee78a1b208382d3a26ec40d142ffc1ecc49ef" - [[package]] name = "parking_lot" -version = "0.8.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa7767817701cce701d5585b9c4db3cdd02086398322c1d7e8bf5094a96a2ce7" +checksum = "6d7744ac029df22dca6284efe4e898991d28e3085c706c972bcd7da4a27a15eb" dependencies = [ + "instant", "lock_api", "parking_lot_core", - "rustc_version", ] [[package]] name = "parking_lot_core" -version = "0.5.0" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb88cb1cb3790baa6776844f968fea3be44956cf184fa1be5a03341f5491278c" +checksum = "fa7a782938e745763fe6907fc6ba86946d72f49fe7e21de074e08128a99fb018" dependencies = [ - "cfg-if", - "cloudabi", + "cfg-if 1.0.0", + "instant", "libc", - "rand", "redox_syscall", - "rustc_version", "smallvec", - "winapi 0.3.8", + "winapi 0.3.9", ] [[package]] name = "predicates" -version = "1.0.1" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53e09015b0d3f5a0ec2d4428f7559bb7b3fff341b4e159fedd1d57fac8b939ff" +checksum = "eeb433456c1a57cc93554dea3ce40b4c19c4057e41c55d4a0f3d84ea71c325aa" dependencies = [ "difference", "float-cmp", @@ -464,15 +479,15 @@ dependencies = [ [[package]] name = "predicates-core" -version = "1.0.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06075c3a3e92559ff8929e7a280684489ea27fe44805174c3ebd9328dcb37178" +checksum = "57e35a3326b75e49aa85f5dc6ec15b41108cf5aee58eabb1f274dd18b73c2451" [[package]] name = "predicates-tree" -version = "1.0.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e63c4859013b38a76eca2414c64911fba30def9e3202ac461a2d22831220124" +checksum = "15f553275e5721409451eb85e15fd9a860a6e5ab4496eb215987502b5f5391f2" dependencies = [ "predicates-core", "treeline", @@ -480,189 +495,54 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "0.4.30" +version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" +checksum = "a152013215dca273577e18d2bf00fa862b89b24169fb78c4c95aeb07992c9cec" dependencies = [ "unicode-xid", ] [[package]] name = "quote" -version = "0.6.12" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "faf4799c5d274f3868a4aae320a0a182cbd2baee377b378f080e16a23e9d80db" +checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" dependencies = [ "proc-macro2", ] -[[package]] -name = "rand" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" -dependencies = [ - "autocfg", - "libc", - "rand_chacha", - "rand_core 0.4.0", - "rand_hc", - "rand_isaac", - "rand_jitter", - "rand_os", - "rand_pcg", - "rand_xorshift", - "winapi 0.3.8", -] - -[[package]] -name = "rand_chacha" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" -dependencies = [ - "autocfg", - "rand_core 0.3.1", -] - -[[package]] -name = "rand_core" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" -dependencies = [ - "rand_core 0.4.0", -] - -[[package]] -name = "rand_core" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0e7a549d590831370895ab7ba4ea0c1b6b011d106b5ff2da6eee112615e6dc0" - -[[package]] -name = "rand_hc" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "rand_isaac" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "rand_jitter" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" -dependencies = [ - "libc", - "rand_core 0.4.0", - "winapi 0.3.8", -] - -[[package]] -name = "rand_os" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" -dependencies = [ - "cloudabi", - "fuchsia-cprng", - "libc", - "rand_core 0.4.0", - "rdrand", - "winapi 0.3.8", -] - -[[package]] -name = "rand_pcg" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" -dependencies = [ - "autocfg", - "rand_core 0.4.0", -] - -[[package]] -name = "rand_xorshift" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "rdrand" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" -dependencies = [ - "rand_core 0.3.1", -] - [[package]] name = "redox_syscall" -version = "0.1.54" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12229c14a0f65c4f1cb046a3b52047cdd9da1f4b30f8a39c5063c8bae515e252" - -[[package]] -name = "redox_termios" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" +checksum = "8270314b5ccceb518e7e578952f0b72b88222d02e8f77f5ecf7abbb673539041" dependencies = [ - "redox_syscall", + "bitflags", ] [[package]] name = "regex" -version = "1.1.6" +version = "1.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f0a0bcab2fd7d1d7c54fa9eae6f43eddeb9ce2e7352f8518a814a4f65d60c58" +checksum = "957056ecddbeba1b26965114e191d2e8589ce74db242b6ea25fc4062427a5c19" dependencies = [ "aho-corasick", "memchr", "regex-syntax", - "thread_local", - "utf8-ranges", ] [[package]] name = "regex-syntax" -version = "0.6.6" +version = "0.6.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcfd8681eebe297b81d98498869d4aae052137651ad7b96822f09ceb690d0a96" -dependencies = [ - "ucd-util", -] - -[[package]] -name = "rustc_version" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -dependencies = [ - "semver", -] +checksum = "24d5f089152e60f62d28b835fbff2cd2e8dc0baf1ac13343bef92ab7eed84548" [[package]] name = "rustlings" version = "4.3.0" dependencies = [ + "argh", "assert_cmd", - "clap", "console 0.7.7", "glob", "indicatif", @@ -675,54 +555,39 @@ dependencies = [ [[package]] name = "ryu" -version = "0.2.8" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b96a9549dc8d48f2c283938303c4b5a77aa29bfbc5b54b084fb1630408899a8f" +checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" [[package]] name = "same-file" -version = "1.0.4" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f20c4be53a8a1ff4c1f1b2bd14570d2f634628709752f0702ecdd2b3f9a5267" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" dependencies = [ "winapi-util", ] [[package]] name = "scopeguard" -version = "1.0.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b42e15e59b18a828bbf5c58ea01debb36b9b096346de35d941dcb89009f24a0d" - -[[package]] -name = "semver" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -dependencies = [ - "semver-parser", -] - -[[package]] -name = "semver-parser" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "serde" -version = "1.0.92" +version = "1.0.125" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32746bf0f26eab52f06af0d0aa1984f641341d06d8d673c693871da2d188c9be" +checksum = "558dc50e1a5a5fa7112ca2ce4effcb321b0300c0d4ccf0776a9f60cd89031171" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.92" +version = "1.0.125" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46a3223d0c9ba936b61c0d2e3e559e3217dbfb8d65d06d26e8b3c25de38bae3e" +checksum = "b093b7a2bb58203b5da3056c05b4ec1fed827dcfdb37347a8841695263b3d06d" dependencies = [ "proc-macro2", "quote", @@ -731,9 +596,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.39" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a23aa71d4a4d43fdbfaac00eff68ba8a06a51759a89ac3304323e800c4dd40d" +checksum = "799e97dc9fdae36a5c8b8f2cae9ce2ee9fdce2058c57a93e6099d919fd982f79" dependencies = [ "itoa", "ryu", @@ -748,21 +613,15 @@ checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" [[package]] name = "smallvec" -version = "0.6.9" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4488ae950c49d403731982257768f48fada354a5203fe81f9bb6f43ca9002be" - -[[package]] -name = "strsim" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" +checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" [[package]] name = "syn" -version = "0.15.34" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1393e4a97a19c01e900df2aec855a29f71cf02c402e2f443b8d2747c25c5dbe" +checksum = "48fe99c6bd8b1cc636890bcc071842de909d902c81ac7dab53ba33c421ab8ffb" dependencies = [ "proc-macro2", "quote", @@ -770,44 +629,24 @@ dependencies = [ ] [[package]] -name = "termion" -version = "1.5.2" +name = "terminal_size" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dde0593aeb8d47accea5392b39350015b5eccb12c0d98044d856983d89548dea" +checksum = "86ca8ced750734db02076f44132d802af0b33b09942331f4459dde8636fd2406" dependencies = [ "libc", - "numtoa", - "redox_syscall", - "redox_termios", + "winapi 0.3.9", ] [[package]] name = "termios" -version = "0.3.1" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b620c5ea021d75a735c943269bb07d30c9b77d6ac6b236bc8b5c496ef05625" +checksum = "411c5bf740737c7918b8b1fe232dca4dc9f8e754b8ad5e20966814001ed0ac6b" dependencies = [ "libc", ] -[[package]] -name = "textwrap" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" -dependencies = [ - "unicode-width", -] - -[[package]] -name = "thread_local" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b" -dependencies = [ - "lazy_static", -] - [[package]] name = "toml" version = "0.4.10" @@ -824,43 +663,31 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7f741b240f1a48843f9b8e0444fb55fb2a4ff67293b50a9179dfd5ea67f8d41" [[package]] -name = "ucd-util" -version = "0.1.3" +name = "unicode-segmentation" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "535c204ee4d8434478593480b8f86ab45ec9aae0e83c568ca81abf0fd0e88f86" +checksum = "bb0d2e7be6ae3a5fa87eed5fb451aff96f2573d2694942e40543ae0bbe19c796" [[package]] name = "unicode-width" -version = "0.1.5" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "882386231c45df4700b275c7ff55b6f3698780a650026380e72dabe76fa46526" +checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" [[package]] name = "unicode-xid" -version = "0.1.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" - -[[package]] -name = "utf8-ranges" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "796f7e48bef87609f7ade7e06495a87d5cd06c7866e6a5cbfceffc558a243737" - -[[package]] -name = "vec_map" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a" +checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" [[package]] name = "walkdir" -version = "2.2.7" +version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d9d7ed3431229a144296213105a390676cc49c9b6a72bd19f3176c98e129fa1" +checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" dependencies = [ "same-file", - "winapi 0.3.8", + "winapi 0.3.9", "winapi-util", ] @@ -872,9 +699,9 @@ checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" [[package]] name = "winapi" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" dependencies = [ "winapi-i686-pc-windows-gnu", "winapi-x86_64-pc-windows-gnu", @@ -894,11 +721,11 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.2" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7168bab6e1daee33b4557efd0e95d5ca70a03706d39fa5f3fe7a236f584b03c9" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" dependencies = [ - "winapi 0.3.8", + "winapi 0.3.9", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index a0564c37..397eb996 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Marisa ", "Carol (Nichols || Goulding) String { } // The mode of the exercise. -#[derive(Deserialize, Copy, Clone)] +#[derive(Deserialize, Copy, Clone, Debug)] #[serde(rename_all = "lowercase")] pub enum Mode { // Indicates that the exercise should be compiled as a binary @@ -42,7 +42,7 @@ pub struct ExerciseList { // A representation of a rustlings exercise. // This is deserialized from the accompanying info.toml file -#[derive(Deserialize)] +#[derive(Deserialize, Debug)] pub struct Exercise { // Name of the exercise pub name: String, diff --git a/src/main.rs b/src/main.rs index 3b7a1942..5af5febc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,7 @@ use crate::exercise::{Exercise, ExerciseList}; use crate::run::run; use crate::verify::verify; -use clap::{crate_version, App, Arg, SubCommand}; +use argh::FromArgs; use console::Emoji; use notify::DebouncedEvent; use notify::{RecommendedWatcher, RecursiveMode, Watcher}; @@ -22,85 +22,91 @@ mod exercise; mod run; mod verify; -fn main() { - let matches = App::new("rustlings") - .version(crate_version!()) - .author("Marisa, Carol Nichols") - .about("Rustlings is a collection of small exercises to get you used to writing and reading Rust code") - .arg( - Arg::with_name("nocapture") - .long("nocapture") - .help("Show outputs from the test exercises") - ) - .subcommand( - SubCommand::with_name("verify") - .alias("v") - .about("Verifies all exercises according to the recommended order") - ) - .subcommand( - SubCommand::with_name("watch") - .alias("w") - .about("Reruns `verify` when files were edited") - ) - .subcommand( - SubCommand::with_name("run") - .alias("r") - .about("Runs/Tests a single exercise") - .arg(Arg::with_name("name").required(true).index(1)), - ) - .subcommand( - SubCommand::with_name("hint") - .alias("h") - .about("Returns a hint for the current exercise") - .arg(Arg::with_name("name").required(true).index(1)), - ) - .subcommand( - SubCommand::with_name("list") - .alias("l") - .about("Lists the exercises available in rustlings") - .arg( - Arg::with_name("paths") - .long("paths") - .short("p") - .conflicts_with("names") - .help("Show only the paths of the exercises") - ) - .arg( - Arg::with_name("names") - .long("names") - .short("n") - .conflicts_with("paths") - .help("Show only the names of the exercises") - ) - .arg( - Arg::with_name("filter") - .long("filter") - .short("f") - .takes_value(true) - .empty_values(false) - .help( - "Provide a string to match the exercise names.\ - \nComma separated patterns are acceptable." - ) - ) - .arg( - Arg::with_name("unsolved") - .long("unsolved") - .short("u") - .conflicts_with("solved") - .help("Display only exercises not yet solved") - ) - .arg( - Arg::with_name("solved") - .long("solved") - .short("s") - .conflicts_with("unsolved") - .help("Display only exercises that have been solved") - ) - ) - .get_matches(); +// In sync with crate version +const VERSION: &str = "4.3.0"; - if matches.subcommand_name().is_none() { +#[derive(FromArgs, PartialEq, Debug)] +/// Rustlings is a collection of small exercises to get you used to writing and reading Rust code +struct Args { + /// show outputs from the test exercises + #[argh(switch)] + nocapture: bool, + /// show the executable version + #[argh(switch, short = 'v')] + version: bool, + #[argh(subcommand)] + nested: Option, +} + +#[derive(FromArgs, PartialEq, Debug)] +#[argh(subcommand)] +enum Subcommands { + Verify(VerifyArgs), + Watch(WatchArgs), + Run(RunArgs), + Hint(HintArgs), + List(ListArgs), +} + +#[derive(FromArgs, PartialEq, Debug)] +#[argh(subcommand, name = "verify")] +/// Verifies all exercises according to the recommended order +struct VerifyArgs {} + +#[derive(FromArgs, PartialEq, Debug)] +#[argh(subcommand, name = "watch")] +/// Reruns `verify` when files were edited +struct WatchArgs {} + +#[derive(FromArgs, PartialEq, Debug)] +#[argh(subcommand, name = "run")] +/// Runs/Tests a single exercise +struct RunArgs { + #[argh(positional)] + /// the name of the exercise + name: String, +} + +#[derive(FromArgs, PartialEq, Debug)] +#[argh(subcommand, name = "hint")] +/// Returns a hint for the given exercise +struct HintArgs { + #[argh(positional)] + /// the name of the exercise + name: String, +} + +#[derive(FromArgs, PartialEq, Debug)] +#[argh(subcommand, name = "list")] +/// Lists the exercises available in Rustlings +struct ListArgs { + #[argh(switch, short = 'p')] + /// show only the paths of the exercises + paths: bool, + #[argh(switch, short = 'n')] + /// show only the names of the exercises + names: bool, + #[argh(option, short = 'f')] + /// provide a string to match exercise names + /// comma separated patterns are acceptable + filter: Option, + #[argh(switch, short = 'u')] + /// display only exercises not yet solved + unsolved: bool, + #[argh(switch, short = 's')] + /// display only exercises that have been solved + solved: bool, +} + +fn main() { + let args: Args = argh::from_env(); + + if args.version { + println!("v{}", VERSION); + std::process::exit(0); + } + + if args.nested.is_none() { println!(); println!(r#" welcome to... "#); println!(r#" _ _ _ "#); @@ -130,144 +136,129 @@ fn main() { let toml_str = &fs::read_to_string("info.toml").unwrap(); let exercises = toml::from_str::(toml_str).unwrap().exercises; - let verbose = matches.is_present("nocapture"); + let verbose = args.nocapture; - // Handle the list command - if let Some(list_m) = matches.subcommand_matches("list") { - if ["paths", "names"].iter().all(|k| !list_m.is_present(k)) { - println!("{:<17}\t{:<46}\t{:<7}", "Name", "Path", "Status"); - } - let filters = list_m.value_of("filter").unwrap_or_default().to_lowercase(); - let mut exercises_done: u16 = 0; - exercises.iter().for_each(|e| { - let fname = format!("{}", e.path.display()); - let filter_cond = filters - .split(',') - .filter(|f| !f.trim().is_empty()) - .any(|f| e.name.contains(&f) || fname.contains(&f)); - let status = if e.looks_done() { - exercises_done = exercises_done + 1; - "Done" - } else { - "Pending" - }; - let solve_cond = { - (e.looks_done() && list_m.is_present("solved")) - || (!e.looks_done() && list_m.is_present("unsolved")) - || (!list_m.is_present("solved") && !list_m.is_present("unsolved")) - }; - if solve_cond && (filter_cond || !list_m.is_present("filter")) { - let line = if list_m.is_present("paths") { - format!("{}\n", fname) - } else if list_m.is_present("names") { - format!("{}\n", e.name) - } else { - format!("{:<17}\t{:<46}\t{:<7}\n", e.name, fname, status) - }; - // Somehow using println! leads to the binary panicking - // when its output is piped. - // So, we're handling a Broken Pipe error and exiting with 0 anyway - let stdout = std::io::stdout(); - { - let mut handle = stdout.lock(); - handle.write_all(line.as_bytes()).unwrap_or_else(|e| { - match e.kind() { - std::io::ErrorKind::BrokenPipe => std::process::exit(0), - _ => std::process::exit(1), - }; - }); - } - } - }); - let percentage_progress = exercises_done as f32 / exercises.len() as f32 * 100.0; - println!( - "Progress: You completed {} / {} exercises ({:.2} %).", - exercises_done, - exercises.len(), - percentage_progress - ); - std::process::exit(0); - } - - // Handle the run command - if let Some(ref matches) = matches.subcommand_matches("run") { - let name = matches.value_of("name").unwrap(); - - let matching_exercise = |e: &&Exercise| name == e.name; - - let exercise = exercises.iter().find(matching_exercise).unwrap_or_else(|| { - println!("No exercise found for your given name!"); - std::process::exit(1) - }); - - run(&exercise, verbose).unwrap_or_else(|_| std::process::exit(1)); - } - - if let Some(ref matches) = matches.subcommand_matches("hint") { - let name = matches.value_of("name").unwrap(); - - let exercise = exercises - .iter() - .find(|e| name == e.name) - .unwrap_or_else(|| { - println!("No exercise found for your given name!"); - std::process::exit(1) - }); - - println!("{}", exercise.hint); - } - - // Handle the verify command - if matches.subcommand_matches("verify").is_some() { - verify(&exercises, verbose).unwrap_or_else(|_| std::process::exit(1)); - } - - // Handle the watch command - if matches.subcommand_matches("watch").is_some() { - if let Err(e) = watch(&exercises, verbose) { - println!( - "Error: Could not watch your progress. Error message was {:?}.", - e - ); - println!("Most likely you've run out of disk space or your 'inotify limit' has been reached."); - std::process::exit(1); - } - println!( - "{emoji} All exercises completed! {emoji}", - emoji = Emoji("πŸŽ‰", "β˜…") - ); - println!(); - println!("+----------------------------------------------------+"); - println!("| You made it to the Fe-nish line! |"); - println!("+-------------------------- ------------------------+"); - println!(" \\/ "); - println!(" β–’β–’ β–’β–’β–’β–’β–’β–’β–’β–’ β–’β–’β–’β–’β–’β–’β–’β–’ β–’β–’ "); - println!(" β–’β–’β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’β–’β–’ "); - println!(" β–’β–’β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’β–’β–’ "); - println!(" β–‘β–‘β–’β–’β–’β–’β–‘β–‘β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’β–‘β–‘β–’β–’β–’β–’ "); - println!(" β–“β–“β–“β–“β–“β–“β–“β–“ β–“β–“ β–“β–“β–ˆβ–ˆ β–“β–“ β–“β–“β–ˆβ–ˆ β–“β–“ β–“β–“β–“β–“β–“β–“β–“β–“ "); - println!(" β–’β–’β–’β–’ β–’β–’ β–ˆβ–ˆβ–ˆβ–ˆ β–’β–’ β–ˆβ–ˆβ–ˆβ–ˆ β–’β–’β–‘β–‘ β–’β–’β–’β–’ "); - println!(" β–’β–’ β–’β–’β–’β–’β–’β–’ β–’β–’β–’β–’β–’β–’ β–’β–’β–’β–’β–’β–’ β–’β–’ "); - println!(" β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–“β–“β–“β–“β–“β–“β–’β–’β–’β–’β–’β–’β–’β–’β–“β–“β–’β–’β–“β–“β–’β–’β–’β–’β–’β–’β–’β–’ "); - println!(" β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’ "); - println!(" β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–ˆβ–ˆβ–’β–’β–’β–’β–’β–’β–ˆβ–ˆβ–’β–’β–’β–’β–’β–’β–’β–’β–’β–’ "); - println!(" β–’β–’ β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–’β–’β–’β–’β–’β–’β–’β–’β–’β–’ β–’β–’ "); - println!(" β–’β–’ β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’ β–’β–’ "); - println!(" β–’β–’ β–’β–’ β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’ β–’β–’ β–’β–’ "); - println!(" β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’ "); - println!(" β–’β–’ β–’β–’ β–’β–’ β–’β–’ "); - println!(); - println!("We hope you enjoyed learning about the various aspects of Rust!"); - println!("If you noticed any issues, please don't hesitate to report them to our repo."); - println!("You can also contribute your own exercises to help the greater community!"); - println!(); - println!("Before reporting an issue or contributing, please read our guidelines:"); - println!("https://github.com/rust-lang/rustlings/blob/main/CONTRIBUTING.md"); - } - - if matches.subcommand_name().is_none() { + let command = args.nested.unwrap_or_else(|| { let text = fs::read_to_string("default_out.txt").unwrap(); println!("{}", text); + std::process::exit(0); + }); + match command { + Subcommands::List(subargs) => { + if !subargs.paths && !subargs.names { + println!("{:<17}\t{:<46}\t{:<7}", "Name", "Path", "Status"); + } + let mut exercises_done: u16 = 0; + let filters = subargs.filter.clone().unwrap_or_default().to_lowercase(); + exercises.iter().for_each(|e| { + let fname = format!("{}", e.path.display()); + let filter_cond = filters + .split(',') + .filter(|f| !f.trim().is_empty()) + .any(|f| e.name.contains(&f) || fname.contains(&f)); + let status = if e.looks_done() { + exercises_done += 1; + "Done" + } else { + "Pending" + }; + let solve_cond = { + (e.looks_done() && subargs.solved) + || (!e.looks_done() && subargs.unsolved) + || (!subargs.solved && !subargs.unsolved) + }; + if solve_cond && (filter_cond || subargs.filter.is_none()) { + let line = if subargs.paths { + format!("{}\n", fname) + } else if subargs.names { + format!("{}\n", e.name) + } else { + format!("{:<17}\t{:<46}\t{:<7}\n", e.name, fname, status) + }; + // Somehow using println! leads to the binary panicking + // when its output is piped. + // So, we're handling a Broken Pipe error and exiting with 0 anyway + let stdout = std::io::stdout(); + { + let mut handle = stdout.lock(); + handle.write_all(line.as_bytes()).unwrap_or_else(|e| { + match e.kind() { + std::io::ErrorKind::BrokenPipe => std::process::exit(0), + _ => std::process::exit(1), + }; + }); + } + } + }); + let percentage_progress = exercises_done as f32 / exercises.len() as f32 * 100.0; + println!( + "Progress: You completed {} / {} exercises ({:.2} %).", + exercises_done, + exercises.len(), + percentage_progress + ); + std::process::exit(0); + } + + Subcommands::Run(subargs) => { + let exercise = find_exercise(subargs.name, exercises); + + run(&exercise, verbose).unwrap_or_else(|_| std::process::exit(1)); + } + + Subcommands::Hint(subargs) => { + let exercise = find_exercise(subargs.name, exercises); + + println!("{}", exercise.hint); + } + + Subcommands::Verify(_subargs) => { + verify(&exercises, verbose).unwrap_or_else(|_| std::process::exit(1)); + } + + Subcommands::Watch(_subargs) => { + if let Err(e) = watch(&exercises, verbose) { + println!( + "Error: Could not watch your progress. Error message was {:?}.", + e + ); + println!("Most likely you've run out of disk space or your 'inotify limit' has been reached."); + std::process::exit(1); + } + println!( + "{emoji} All exercises completed! {emoji}", + emoji = Emoji("πŸŽ‰", "β˜…") + ); + println!(); + println!("+----------------------------------------------------+"); + println!("| You made it to the Fe-nish line! |"); + println!("+-------------------------- ------------------------+"); + println!(" \\/ "); + println!(" β–’β–’ β–’β–’β–’β–’β–’β–’β–’β–’ β–’β–’β–’β–’β–’β–’β–’β–’ β–’β–’ "); + println!(" β–’β–’β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’β–’β–’ "); + println!(" β–’β–’β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’β–’β–’ "); + println!(" β–‘β–‘β–’β–’β–’β–’β–‘β–‘β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’β–‘β–‘β–’β–’β–’β–’ "); + println!(" β–“β–“β–“β–“β–“β–“β–“β–“ β–“β–“ β–“β–“β–ˆβ–ˆ β–“β–“ β–“β–“β–ˆβ–ˆ β–“β–“ β–“β–“β–“β–“β–“β–“β–“β–“ "); + println!(" β–’β–’β–’β–’ β–’β–’ β–ˆβ–ˆβ–ˆβ–ˆ β–’β–’ β–ˆβ–ˆβ–ˆβ–ˆ β–’β–’β–‘β–‘ β–’β–’β–’β–’ "); + println!(" β–’β–’ β–’β–’β–’β–’β–’β–’ β–’β–’β–’β–’β–’β–’ β–’β–’β–’β–’β–’β–’ β–’β–’ "); + println!(" β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–“β–“β–“β–“β–“β–“β–’β–’β–’β–’β–’β–’β–’β–’β–“β–“β–’β–’β–“β–“β–’β–’β–’β–’β–’β–’β–’β–’ "); + println!(" β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’ "); + println!(" β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–ˆβ–ˆβ–’β–’β–’β–’β–’β–’β–ˆβ–ˆβ–’β–’β–’β–’β–’β–’β–’β–’β–’β–’ "); + println!(" β–’β–’ β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–’β–’β–’β–’β–’β–’β–’β–’β–’β–’ β–’β–’ "); + println!(" β–’β–’ β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’ β–’β–’ "); + println!(" β–’β–’ β–’β–’ β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’ β–’β–’ β–’β–’ "); + println!(" β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’ "); + println!(" β–’β–’ β–’β–’ β–’β–’ β–’β–’ "); + println!(); + println!("We hope you enjoyed learning about the various aspects of Rust!"); + println!( + "If you noticed any issues, please don't hesitate to report them to our repo." + ); + println!("You can also contribute your own exercises to help the greater community!"); + println!(); + println!("Before reporting an issue or contributing, please read our guidelines:"); + println!("https://github.com/rust-lang/rustlings/blob/main/CONTRIBUTING.md"); + } } } @@ -294,6 +285,18 @@ fn spawn_watch_shell(failed_exercise_hint: &Arc>>) { }); } +fn find_exercise(name: String, exercises: Vec) -> Exercise { + let matching_exercise = |e: &Exercise| name == e.name; + + exercises + .into_iter() + .find(matching_exercise) + .unwrap_or_else(|| { + println!("No exercise found for your given name!"); + std::process::exit(1) + }) +} + fn watch(exercises: &[Exercise], verbose: bool) -> notify::Result<()> { /* Clears the terminal with an ANSI escape code. Works in UNIX and newer Windows terminals. */ From 6177b6e126852027b689ebab4e0796b2984f987b Mon Sep 17 00:00:00 2001 From: mokou Date: Wed, 21 Apr 2021 14:47:53 +0200 Subject: [PATCH 184/282] chore: Fix integration tests --- tests/integration_tests.rs | 67 ++++++++++++++------------------------ 1 file changed, 24 insertions(+), 43 deletions(-) diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs index 1bd3bf7e..be9af965 100644 --- a/tests/integration_tests.rs +++ b/tests/integration_tests.rs @@ -24,7 +24,7 @@ fn fails_when_in_wrong_dir() { fn verify_all_success() { Command::cargo_bin("rustlings") .unwrap() - .arg("v") + .arg("verify") .current_dir("tests/fixture/success") .assert() .success(); @@ -34,7 +34,7 @@ fn verify_all_success() { fn verify_fails_if_some_fails() { Command::cargo_bin("rustlings") .unwrap() - .arg("v") + .arg("verify") .current_dir("tests/fixture/failure") .assert() .code(1); @@ -44,7 +44,7 @@ fn verify_fails_if_some_fails() { fn run_single_compile_success() { Command::cargo_bin("rustlings") .unwrap() - .args(&["r", "compSuccess"]) + .args(&["run", "compSuccess"]) .current_dir("tests/fixture/success/") .assert() .success(); @@ -54,7 +54,7 @@ fn run_single_compile_success() { fn run_single_compile_failure() { Command::cargo_bin("rustlings") .unwrap() - .args(&["r", "compFailure"]) + .args(&["run", "compFailure"]) .current_dir("tests/fixture/failure/") .assert() .code(1); @@ -64,7 +64,7 @@ fn run_single_compile_failure() { fn run_single_test_success() { Command::cargo_bin("rustlings") .unwrap() - .args(&["r", "testSuccess"]) + .args(&["run", "testSuccess"]) .current_dir("tests/fixture/success/") .assert() .success(); @@ -74,7 +74,7 @@ fn run_single_test_success() { fn run_single_test_failure() { Command::cargo_bin("rustlings") .unwrap() - .args(&["r", "testFailure"]) + .args(&["run", "testFailure"]) .current_dir("tests/fixture/failure/") .assert() .code(1); @@ -84,7 +84,7 @@ fn run_single_test_failure() { fn run_single_test_not_passed() { Command::cargo_bin("rustlings") .unwrap() - .args(&["r", "testNotPassed.rs"]) + .args(&["run", "testNotPassed.rs"]) .current_dir("tests/fixture/failure/") .assert() .code(1); @@ -94,7 +94,7 @@ fn run_single_test_not_passed() { fn run_single_test_no_filename() { Command::cargo_bin("rustlings") .unwrap() - .arg("r") + .arg("run") .current_dir("tests/fixture/") .assert() .code(1); @@ -104,7 +104,7 @@ fn run_single_test_no_filename() { fn run_single_test_no_exercise() { Command::cargo_bin("rustlings") .unwrap() - .args(&["r", "compNoExercise.rs"]) + .args(&["run", "compNoExercise.rs"]) .current_dir("tests/fixture/failure") .assert() .code(1); @@ -114,7 +114,7 @@ fn run_single_test_no_exercise() { fn get_hint_for_single_test() { Command::cargo_bin("rustlings") .unwrap() - .args(&["h", "testFailure"]) + .args(&["hint", "testFailure"]) .current_dir("tests/fixture/failure") .assert() .code(0) @@ -131,10 +131,15 @@ fn all_exercises_require_confirmation() { file.read_to_string(&mut s).unwrap(); s }; - source.matches("// I AM NOT DONE").next().unwrap_or_else(|| panic!( - "There should be an `I AM NOT DONE` annotation in {:?}", - path - )); + source + .matches("// I AM NOT DONE") + .next() + .unwrap_or_else(|| { + panic!( + "There should be an `I AM NOT DONE` annotation in {:?}", + path + ) + }); } } @@ -142,7 +147,7 @@ fn all_exercises_require_confirmation() { fn run_compile_exercise_does_not_prompt() { Command::cargo_bin("rustlings") .unwrap() - .args(&["r", "pending_exercise"]) + .args(&["run", "pending_exercise"]) .current_dir("tests/fixture/state") .assert() .code(0) @@ -153,7 +158,7 @@ fn run_compile_exercise_does_not_prompt() { fn run_test_exercise_does_not_prompt() { Command::cargo_bin("rustlings") .unwrap() - .args(&["r", "pending_test_exercise"]) + .args(&["run", "pending_test_exercise"]) .current_dir("tests/fixture/state") .assert() .code(0) @@ -164,7 +169,7 @@ fn run_test_exercise_does_not_prompt() { fn run_single_test_success_with_output() { Command::cargo_bin("rustlings") .unwrap() - .args(&["--nocapture", "r", "testSuccess"]) + .args(&["--nocapture", "run", "testSuccess"]) .current_dir("tests/fixture/success/") .assert() .code(0) @@ -175,7 +180,7 @@ fn run_single_test_success_with_output() { fn run_single_test_success_without_output() { Command::cargo_bin("rustlings") .unwrap() - .args(&["r", "testSuccess"]) + .args(&["run", "testSuccess"]) .current_dir("tests/fixture/success/") .assert() .code(0) @@ -192,26 +197,6 @@ fn run_rustlings_list() { .success(); } -#[test] -fn run_rustlings_list_conflicting_display_options() { - Command::cargo_bin("rustlings") - .unwrap() - .args(&["list", "--names", "--paths"]) - .current_dir("tests/fixture/success") - .assert() - .failure(); -} - -#[test] -fn run_rustlings_list_conflicting_solve_options() { - Command::cargo_bin("rustlings") - .unwrap() - .args(&["list", "--solved", "--unsolved"]) - .current_dir("tests/fixture/success") - .assert() - .failure(); -} - #[test] fn run_rustlings_list_no_pending() { Command::cargo_bin("rustlings") @@ -231,10 +216,7 @@ fn run_rustlings_list_both_done_and_pending() { .current_dir("tests/fixture/state") .assert() .success() - .stdout( - predicates::str::contains("Done") - .and(predicates::str::contains("Pending")) - ); + .stdout(predicates::str::contains("Done").and(predicates::str::contains("Pending"))); } #[test] @@ -258,4 +240,3 @@ fn run_rustlings_list_without_done() { .success() .stdout(predicates::str::contains("Done").not()); } - From 81be40448777fa338ebced3b0bfc1b32d6370313 Mon Sep 17 00:00:00 2001 From: Brandon Macer Date: Wed, 21 Apr 2021 08:50:03 -0400 Subject: [PATCH 185/282] feat(arc1): Add more details to description and hint (#710) Co-authored-by: bmacer Co-authored-by: marisa Co-authored-by: Roberto Vidal --- exercises/standard_library_types/arc1.rs | 19 +++++++++++++++++-- info.toml | 7 ++++++- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/exercises/standard_library_types/arc1.rs b/exercises/standard_library_types/arc1.rs index 4ad649f1..d167380c 100644 --- a/exercises/standard_library_types/arc1.rs +++ b/exercises/standard_library_types/arc1.rs @@ -1,7 +1,21 @@ // arc1.rs +// In this exercise, we are given a Vec of u32 called "numbers" with values ranging +// from 0 to 99 -- [ 0, 1, 2, ..., 98, 99 ] +// We would like to use this set of numbers within 8 different threads simultaneously. +// Each thread is going to get the sum of every eighth value, with an offset. +// The first thread (offset 0), will sum 0, 8, 16, ... +// The second thread (offset 1), will sum 1, 9, 17, ... +// The third thread (offset 2), will sum 2, 10, 18, ... +// ... +// The eighth thread (offset 7), will sum 7, 15, 23, ... + +// Because we are using threads, our values need to be thread-safe. Therefore, +// we are using Arc. We need to make a change in each of the two TODOs. + + // Make this code compile by filling in a value for `shared_numbers` where the -// TODO comment is and create an initial binding for `child_numbers` -// somewhere. Try not to create any copies of the `numbers` Vec! +// first TODO comment is, and create an initial binding for `child_numbers` +// where the second TODO comment is. Try not to create any copies of the `numbers` Vec! // Execute `rustlings hint arc1` for hints :) // I AM NOT DONE @@ -16,6 +30,7 @@ fn main() { let mut joinhandles = Vec::new(); for offset in 0..8 { + let child_numbers = // TODO joinhandles.push(thread::spawn(move || { let mut i = offset; let mut sum = 0; diff --git a/info.toml b/info.toml index 36dcbe90..82e11952 100644 --- a/info.toml +++ b/info.toml @@ -679,7 +679,12 @@ to avoid creating a copy of `numbers`, you'll need to create `child_numbers` inside the loop but still in the main thread. `child_numbers` should be a clone of the Arc of the numbers instead of a -thread-local copy of the numbers.""" +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: +https://doc.rust-lang.org/stable/book/ch16-00-concurrency.html +""" [[exercises]] name = "iterators1" From 293dfb35d53aba5f9566f980197f93545ed2216d Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Wed, 21 Apr 2021 12:50:26 +0000 Subject: [PATCH 186/282] docs: update README.md [skip ci] --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2d2cb0ef..e76a04dc 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -[![All Contributors](https://img.shields.io/badge/all_contributors-89-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-90-orange.svg?style=flat-square)](#contributors-) # rustlings πŸ¦€β€οΈ @@ -277,6 +277,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Shao Yang Hong

πŸ–‹ +
Brandon Macer

πŸ–‹ From 8d0490bd70c7f4227a5aa43b259359a13117435d Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Wed, 21 Apr 2021 12:50:27 +0000 Subject: [PATCH 187/282] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index e820b426..2820d18a 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -829,6 +829,15 @@ "contributions": [ "content" ] + }, + { + "login": "bmacer", + "name": "Brandon Macer", + "avatar_url": "https://avatars.githubusercontent.com/u/13931806?v=4", + "profile": "https://github.com/bmacer", + "contributions": [ + "content" + ] } ], "contributorsPerLine": 8, From 347f30bd867343c5ace1097e085a1f7e356553f7 Mon Sep 17 00:00:00 2001 From: mokou Date: Wed, 21 Apr 2021 16:21:56 +0200 Subject: [PATCH 188/282] fix(main): Let find_exercise work with borrows --- src/main.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/main.rs b/src/main.rs index 5af5febc..a95a09d9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -201,13 +201,13 @@ fn main() { } Subcommands::Run(subargs) => { - let exercise = find_exercise(subargs.name, exercises); + let exercise = find_exercise(&subargs.name, &exercises); run(&exercise, verbose).unwrap_or_else(|_| std::process::exit(1)); } Subcommands::Hint(subargs) => { - let exercise = find_exercise(subargs.name, exercises); + let exercise = find_exercise(&subargs.name, &exercises); println!("{}", exercise.hint); } @@ -285,14 +285,12 @@ fn spawn_watch_shell(failed_exercise_hint: &Arc>>) { }); } -fn find_exercise(name: String, exercises: Vec) -> Exercise { - let matching_exercise = |e: &Exercise| name == e.name; - +fn find_exercise<'a>(name: &str, exercises: &'a [Exercise]) -> &'a Exercise { exercises - .into_iter() - .find(matching_exercise) + .iter() + .find(|e| e.name == name) .unwrap_or_else(|| { - println!("No exercise found for your given name!"); + println!("No exercise found for '{}'!", name); std::process::exit(1) }) } From 1120db57a6c20966184eb8f731804604270ff2f1 Mon Sep 17 00:00:00 2001 From: Zerotask Date: Thu, 22 Apr 2021 21:32:29 +0200 Subject: [PATCH 189/282] docs(errors): add additional help for Result/Boxing add additional help information provided by the rust by example book --- exercises/error_handling/README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/exercises/error_handling/README.md b/exercises/error_handling/README.md index 77a58d18..478510a4 100644 --- a/exercises/error_handling/README.md +++ b/exercises/error_handling/README.md @@ -3,3 +3,9 @@ For this exercise check out the sections: - [Generics](https://doc.rust-lang.org/book/ch10-01-syntax.html) of the Rust Book. + +or alternatively, check out the sections: +- [Result](https://doc.rust-lang.org/rust-by-example/error/result.html) +- [Boxing errors](https://doc.rust-lang.org/rust-by-example/error/multiple_error_types/boxing_errors.html) + +of the Rust By Example Book. From f253103a314b9cdbda1d6271015cf64e5b2347bd Mon Sep 17 00:00:00 2001 From: Zerotask Date: Thu, 22 Apr 2021 22:11:04 +0200 Subject: [PATCH 190/282] docs(generics): add bounds help add help for bounds provided by the rust by example book --- exercises/generics/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/exercises/generics/README.md b/exercises/generics/README.md index 7105f06f..12170d4a 100644 --- a/exercises/generics/README.md +++ b/exercises/generics/README.md @@ -4,4 +4,5 @@ In this section you'll learn about saving yourself many lines of code with gener ### Book Sections -- [Generic Data Types](https://doc.rust-lang.org/stable/book/ch10-01-syntax.html) \ No newline at end of file +- [Generic Data Types](https://doc.rust-lang.org/stable/book/ch10-01-syntax.html) +- [Bounds](https://doc.rust-lang.org/rust-by-example/generics/bounds.html) From 249ad44cc03974fd34708c23d9832b1729c6e844 Mon Sep 17 00:00:00 2001 From: Zerotask Date: Fri, 23 Apr 2021 19:54:31 +0200 Subject: [PATCH 191/282] docs(exercises): updated all exercises readme files all exercises readme files now have a unified structure and a description --- exercises/clippy/README.md | 6 ++++-- exercises/collections/README.md | 6 ++++-- exercises/conversions/README.md | 9 +++++---- exercises/enums/README.md | 4 ++-- exercises/error_handling/README.md | 14 +++++++------- exercises/functions/README.md | 4 ++-- exercises/generics/README.md | 9 ++++++--- exercises/if/README.md | 4 ++-- exercises/macros/README.md | 4 ++-- exercises/modules/README.md | 4 ++-- exercises/move_semantics/README.md | 4 ++-- exercises/option/README.md | 15 ++++++++++++--- exercises/primitive_types/README.md | 4 ++-- exercises/standard_library_types/README.md | 11 ++++++++--- exercises/strings/README.md | 4 ++-- exercises/structs/README.md | 4 ++-- exercises/tests/README.md | 4 ++-- exercises/threads/README.md | 10 +++++++++- exercises/traits/README.md | 11 +++++------ exercises/variables/README.md | 8 +++++--- 20 files changed, 85 insertions(+), 54 deletions(-) diff --git a/exercises/clippy/README.md b/exercises/clippy/README.md index 60a12fe5..55438af6 100644 --- a/exercises/clippy/README.md +++ b/exercises/clippy/README.md @@ -1,8 +1,10 @@ -### Clippy +# Clippy The Clippy tool is a collection of lints to analyze your code so you can catch common mistakes and improve your Rust code. If you used the installation script for Rustlings, Clippy should be already installed. If not you can install it manually via `rustup component add clippy`. -For more information about Clippy lints, please see [their documentation page](https://rust-lang.github.io/rust-clippy/master/). +## Further information + +- [GitHub Repository](https://github.com/rust-lang/rust-clippy). diff --git a/exercises/collections/README.md b/exercises/collections/README.md index af87863b..0291bc87 100644 --- a/exercises/collections/README.md +++ b/exercises/collections/README.md @@ -1,4 +1,4 @@ -### Collections +# Collections Rust’s standard library includes a number of very useful data structures called collections. Most other data types represent one @@ -17,4 +17,6 @@ structures that are used very often in Rust programs: You may also know this by the names [*unordered map* in C++](https://en.cppreference.com/w/cpp/container/unordered_map), [*dictionary* in Python](https://docs.python.org/3/tutorial/datastructures.html#dictionaries) or an *associative array* in other languages. -[Rust book chapter](https://doc.rust-lang.org/stable/book/ch08-01-vectors.html) +## Further information + +- [Storing Lists of Values with Vectors](https://doc.rust-lang.org/stable/book/ch08-01-vectors.html) diff --git a/exercises/conversions/README.md b/exercises/conversions/README.md index 114bd428..8d7da93e 100644 --- a/exercises/conversions/README.md +++ b/exercises/conversions/README.md @@ -1,5 +1,4 @@ -### Type conversions - +# Type conversions Rust offers a multitude of ways to convert a value of a given type into another type. @@ -15,6 +14,8 @@ Furthermore, the `std::str` module offers a trait called [`FromStr`](https://doc These should be the main ways ***within the standard library*** to convert data into your desired types. -#### Book Sections +## Further information -These are not directly covered in the book, but the standard library has great documentation for [conversions here](https://doc.rust-lang.org/std/convert/index.html). The `FromStr` trait is also covered [here](https://doc.rust-lang.org/std/str/trait.FromStr.html). \ No newline at end of file +These are not directly covered in the book, but the standard library has a great documentation for it. +- [conversions](https://doc.rust-lang.org/std/convert/index.html) +- [`FromStr` trait](https://doc.rust-lang.org/std/str/trait.FromStr.html) \ No newline at end of file diff --git a/exercises/enums/README.md b/exercises/enums/README.md index 091f5d04..30d4d91d 100644 --- a/exercises/enums/README.md +++ b/exercises/enums/README.md @@ -1,10 +1,10 @@ -### Enums +# Enums Rust allows you to define types called "enums" which enumerate possible values. Enums are a feature in many languages, but their capabilities differ in each language. Rust’s enums are most similar to algebraic data types in functional languages, such as F#, OCaml, and Haskell. Useful in combination with enums is Rust's "pattern matching" facility, which makes it easy to run different code for different values of an enumeration. -#### Book Sections +## Further information - [Enums](https://doc.rust-lang.org/book/ch06-00-enums.html) - [Pattern syntax](https://doc.rust-lang.org/book/ch18-03-pattern-syntax.html) diff --git a/exercises/error_handling/README.md b/exercises/error_handling/README.md index 478510a4..5255ace9 100644 --- a/exercises/error_handling/README.md +++ b/exercises/error_handling/README.md @@ -1,11 +1,11 @@ -For this exercise check out the sections: +# Error handling +Most errors aren’t serious enough to require the program to stop entirely. +Sometimes, when a function fails, it’s for a reason that you can easily interpret and respond to. +For example, if you try to open a file and that operation fails because the file doesn’t exist, you might want to create the file instead of terminating the process. + +## Further information + - [Error Handling](https://doc.rust-lang.org/book/ch09-02-recoverable-errors-with-result.html) - [Generics](https://doc.rust-lang.org/book/ch10-01-syntax.html) - -of the Rust Book. - -or alternatively, check out the sections: - [Result](https://doc.rust-lang.org/rust-by-example/error/result.html) - [Boxing errors](https://doc.rust-lang.org/rust-by-example/error/multiple_error_types/boxing_errors.html) - -of the Rust By Example Book. diff --git a/exercises/functions/README.md b/exercises/functions/README.md index 351ae023..66547bd4 100644 --- a/exercises/functions/README.md +++ b/exercises/functions/README.md @@ -1,7 +1,7 @@ -### Functions +# Functions Here, you'll learn how to write functions and how Rust's compiler can trace things way back. -#### Book Sections +## Further information - [How Functions Work](https://doc.rust-lang.org/book/ch03-03-how-functions-work.html) diff --git a/exercises/generics/README.md b/exercises/generics/README.md index 12170d4a..de46d503 100644 --- a/exercises/generics/README.md +++ b/exercises/generics/README.md @@ -1,8 +1,11 @@ -### Generics +# Generics -In this section you'll learn about saving yourself many lines of code with generics! +Generics is the topic of generalizing types and functionalities to broader cases. +This is extremely useful for reducing code duplication in many ways, but can call for rather involving syntax. +Namely, being generic requires taking great care to specify over which types a generic type is actually considered valid. +The simplest and most common use of generics is for type parameters. -### Book Sections +## Further information - [Generic Data Types](https://doc.rust-lang.org/stable/book/ch10-01-syntax.html) - [Bounds](https://doc.rust-lang.org/rust-by-example/generics/bounds.html) diff --git a/exercises/if/README.md b/exercises/if/README.md index b1157218..528d9886 100644 --- a/exercises/if/README.md +++ b/exercises/if/README.md @@ -1,7 +1,7 @@ -### If +# If `if`, the most basic type of control flow, is what you'll learn here. -#### Book Sections +## Further information - [Control Flow - if expressions](https://doc.rust-lang.org/book/ch03-05-control-flow.html#if-expressions) diff --git a/exercises/macros/README.md b/exercises/macros/README.md index b48b880a..319d8408 100644 --- a/exercises/macros/README.md +++ b/exercises/macros/README.md @@ -1,10 +1,10 @@ -### Macros +# Macros Rust's macro system is very powerful, but also kind of difficult to wrap your head around. We're not going to teach you how to write your own fully-featured macros. Instead, we'll show you how to use and create them. -#### Book Sections +## Further information - [Macros](https://doc.rust-lang.org/book/ch19-06-macros.html) - [The Little Book of Rust Macros](https://danielkeep.github.io/tlborm/book/index.html) diff --git a/exercises/modules/README.md b/exercises/modules/README.md index bb765106..6582b000 100644 --- a/exercises/modules/README.md +++ b/exercises/modules/README.md @@ -1,7 +1,7 @@ -### Modules +# Modules In this section we'll give you an introduction to Rust's module system. -#### Book Sections +## Further information - [The Module System](https://doc.rust-lang.org/book/ch07-02-defining-modules-to-control-scope-and-privacy.html) diff --git a/exercises/move_semantics/README.md b/exercises/move_semantics/README.md index 6842af7c..54ddd8e6 100644 --- a/exercises/move_semantics/README.md +++ b/exercises/move_semantics/README.md @@ -1,8 +1,8 @@ -### Move Semantics +# Move Semantics These exercises are adapted from [pnkfelix](https://github.com/pnkfelix)'s [Rust Tutorial](https://pnkfelix.github.io/rust-examples-icfp2014/) -- Thank you Felix!!! -#### Book Sections +## Further information For this section, the book links are especially important. diff --git a/exercises/option/README.md b/exercises/option/README.md index d17b79cc..a304bb44 100644 --- a/exercises/option/README.md +++ b/exercises/option/README.md @@ -1,8 +1,17 @@ -### Option +# Option -#### Book Sections +Type Option represents an optional value: every Option is either Some and contains a value, or None, and does not. +Option types are very common in Rust code, as they have a number of uses: +- Initial values +- Return values for functions that are not defined over their entire input range (partial functions) +- Return value for otherwise reporting simple errors, where None is returned on error +- Optional struct fields +- Struct fields that can be loaned or "taken" +- Optional function arguments +- Nullable pointers +- Swapping things out of difficult situations -To learn about Option, check out these links: +## Further Information - [Option Enum Format](https://doc.rust-lang.org/stable/book/ch10-01-syntax.html#in-enum-definitions) - [Option Module Documentation](https://doc.rust-lang.org/std/option/) diff --git a/exercises/primitive_types/README.md b/exercises/primitive_types/README.md index daa70eea..cea69b02 100644 --- a/exercises/primitive_types/README.md +++ b/exercises/primitive_types/README.md @@ -1,9 +1,9 @@ -### Primitive Types +# Primitive Types Rust has a couple of basic types that are directly implemented into the compiler. In this section, we'll go through the most important ones. -#### Book Sections +## Further information - [Data Types](https://doc.rust-lang.org/stable/book/ch03-02-data-types.html) - [The Slice Type](https://doc.rust-lang.org/stable/book/ch04-03-slices.html) diff --git a/exercises/standard_library_types/README.md b/exercises/standard_library_types/README.md index 8b53dd81..809d61fe 100644 --- a/exercises/standard_library_types/README.md +++ b/exercises/standard_library_types/README.md @@ -1,5 +1,10 @@ -For the Box exercise check out the chapter [Using Box to Point to Data on the Heap](https://doc.rust-lang.org/book/ch15-01-box.html). +# Standard library types -For the Arc exercise check out the chapter [Shared-State Concurrency](https://doc.rust-lang.org/book/ch16-03-shared-state.html) of the Rust Book. +This section will teach you about Box, Shared-State Concurrency and Iterators. -For the Iterator exercise check out the chapters [Iterator](https://doc.rust-lang.org/book/ch13-02-iterators.html) of the Rust Book and the [Iterator documentation](https://doc.rust-lang.org/stable/std/iter/). +## Further information + +- [Using Box to Point to Data on the Heap](https://doc.rust-lang.org/book/ch15-01-box.html) +- [Shared-State Concurrency](https://doc.rust-lang.org/book/ch16-03-shared-state.html) +- [Iterator](https://doc.rust-lang.org/book/ch13-02-iterators.html) +- [Iterator documentation](https://doc.rust-lang.org/stable/std/iter/) diff --git a/exercises/strings/README.md b/exercises/strings/README.md index 38d24c84..fa2104cc 100644 --- a/exercises/strings/README.md +++ b/exercises/strings/README.md @@ -1,9 +1,9 @@ -### Strings +# Strings Rust has two string types, a string slice (`&str`) and an owned string (`String`). We're not going to dictate when you should use which one, but we'll show you how to identify and create them, as well as use them. -#### Book Sections +## Further information - [Strings](https://doc.rust-lang.org/book/ch08-02-strings.html) diff --git a/exercises/structs/README.md b/exercises/structs/README.md index 58e5a6a4..3fc1fdc9 100644 --- a/exercises/structs/README.md +++ b/exercises/structs/README.md @@ -1,8 +1,8 @@ -### Structs +# Structs Rust has three struct types: a classic C struct, a tuple struct, and a unit struct. -#### Book Sections +## Further information - [Structures](https://doc.rust-lang.org/book/ch05-01-defining-structs.html) - [Method Syntax](https://doc.rust-lang.org/book/ch05-03-method-syntax.html) diff --git a/exercises/tests/README.md b/exercises/tests/README.md index dbb14a83..27c6818d 100644 --- a/exercises/tests/README.md +++ b/exercises/tests/README.md @@ -1,7 +1,7 @@ -### Tests +# Tests Going out of order from the book to cover tests -- many of the following exercises will ask you to make tests pass! -#### Book Sections +## Further information - [Writing Tests](https://doc.rust-lang.org/book/ch11-01-writing-tests.html) diff --git a/exercises/threads/README.md b/exercises/threads/README.md index 2024292f..d0866947 100644 --- a/exercises/threads/README.md +++ b/exercises/threads/README.md @@ -1 +1,9 @@ -For this exercise check out the [Dining Philosophers example](https://doc.rust-lang.org/1.4.0/book/dining-philosophers.html) and the chapter [Concurrency](https://doc.rust-lang.org/book/ch16-01-threads.html) of the Rust Book. \ No newline at end of file +# Threads + +In most current operating systems, an executed program’s code is run in a process, and the operating system manages multiple processes at once. +Within your program, you can also have independent parts that run simultaneously. The features that run these independent parts are called threads. + +## Further information + +- [Dining Philosophers example](https://doc.rust-lang.org/1.4.0/book/dining-philosophers.html) +- [Using Threads to Run Code Simultaneously](https://doc.rust-lang.org/book/ch16-01-threads.html) diff --git a/exercises/traits/README.md b/exercises/traits/README.md index 8cd03ec4..de67acd0 100644 --- a/exercises/traits/README.md +++ b/exercises/traits/README.md @@ -1,4 +1,4 @@ -### Traits +# Traits A trait is a collection of methods. @@ -7,14 +7,13 @@ Data types can implement traits. To do so, the methods making up the trait are d In this way, traits are somewhat similar to Java interfaces and C++ abstract classes. Some additional common Rust traits include: - -+ `Clone` (the `clone` method), -+ `Display` (which allows formatted display via `{}`), and -+ `Debug` (which allows formatted display via `{:?}`). +- `Clone` (the `clone` method) +- `Display` (which allows formatted display via `{}`) +- `Debug` (which allows formatted display via `{:?}`) Because traits indicate shared behavior between data types, they are useful when writing generics. -#### Book Sections +## Further information - [Traits](https://doc.rust-lang.org/book/ch10-02-traits.html) diff --git a/exercises/variables/README.md b/exercises/variables/README.md index 1e2eb596..11a7a78a 100644 --- a/exercises/variables/README.md +++ b/exercises/variables/README.md @@ -1,7 +1,9 @@ -### Variables +# Variables -Here you'll learn about simple variables. +In Rust, variables are immutable by default. +When a variable is immutable, once a value is bound to a name, you can’t change that value. +You can make them mutable by adding mut in front of the variable name. -#### Book Sections +## Further information - [Variables and Mutability](https://doc.rust-lang.org/book/ch03-01-variables-and-mutability.html) From eefa6562327cd537fc33b1688caf8d8512ef46de Mon Sep 17 00:00:00 2001 From: Zerotask Date: Fri, 23 Apr 2021 20:07:32 +0200 Subject: [PATCH 192/282] chore(deps): update cargo dependencies --- Cargo.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 367881c7..fb361569 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -522,9 +522,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.4.5" +version = "1.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "957056ecddbeba1b26965114e191d2e8589ce74db242b6ea25fc4062427a5c19" +checksum = "2a26af418b574bd56588335b3a3659a65725d4e636eb1016c2f9e3b38c7cc759" dependencies = [ "aho-corasick", "memchr", @@ -607,9 +607,9 @@ dependencies = [ [[package]] name = "slab" -version = "0.4.2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" +checksum = "f173ac3d1a7e3b28003f40de0b5ce7fe2710f9b9dc3fc38664cebee46b3b6527" [[package]] name = "smallvec" @@ -619,9 +619,9 @@ checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" [[package]] name = "syn" -version = "1.0.69" +version = "1.0.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48fe99c6bd8b1cc636890bcc071842de909d902c81ac7dab53ba33c421ab8ffb" +checksum = "b9505f307c872bab8eb46f77ae357c8eba1fdacead58ee5a850116b1d7f82883" dependencies = [ "proc-macro2", "quote", From cf42ddc4497a2577e8c8e9206523322b3a2b9fc2 Mon Sep 17 00:00:00 2001 From: Zerotask Date: Fri, 23 Apr 2021 20:28:55 +0200 Subject: [PATCH 193/282] chore(watch): add hint for the exercises README.md rustlings watch will now show an additional hint for the corresponding README.me --- src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index a95a09d9..bc1b71e4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -264,7 +264,7 @@ fn main() { fn spawn_watch_shell(failed_exercise_hint: &Arc>>) { let failed_exercise_hint = Arc::clone(failed_exercise_hint); - println!("Type 'hint' to get help or 'clear' to clear the screen"); + println!("Type 'hint' or open the corresponding README.md file to get help or type 'clear' to clear the screen."); thread::spawn(move || loop { let mut input = String::new(); match io::stdin().read_line(&mut input) { From 84461c20cbaf97a67baa55afc16989aab3e3c02d Mon Sep 17 00:00:00 2001 From: mokou Date: Sat, 24 Apr 2021 11:57:00 +0200 Subject: [PATCH 194/282] release: 4.4.0 --- CHANGELOG.md | 45 +++++++++++++++++++++++++++++++++++++++++++++ Cargo.lock | 2 +- Cargo.toml | 2 +- README.md | 2 +- src/main.rs | 2 +- 5 files changed, 49 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3988826e..1686bdd6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,48 @@ + +## 4.4.0 (2021-04-24) + + +#### Bug Fixes + +* Fix spelling error in main.rs ([91ee27f2](https://github.com/rust-lang/rustlings/commit/91ee27f22bd3797a9db57e5fd430801c170c5db8)) +* typo in default out text ([644c49f1](https://github.com/rust-lang/rustlings/commit/644c49f1e04cbb24e95872b3a52b07d692ae3bc8)) +* **collections:** Naming exercises for vectors and hashmap ([bef39b12](https://github.com/rust-lang/rustlings/commit/bef39b125961310b34b34871e480a82e82af4678)) +* **from_str:** + * Correct typos ([5f7c89f8](https://github.com/rust-lang/rustlings/commit/5f7c89f85db1f33da01911eaa479c3a2d4721678)) + * test for error instead of unwrap/should_panic ([15e71535](https://github.com/rust-lang/rustlings/commit/15e71535f37cfaed36e22eb778728d186e2104ab)) + * use trait objects for from_str ([c3e7b831](https://github.com/rust-lang/rustlings/commit/c3e7b831786c9172ed8bd5d150f3c432f242fba9)) +* **functions3:** improve function argument type (#687) ([a6509cc4](https://github.com/rust-lang/rustlings/commit/a6509cc4d545d8825f01ddf7ee37823b372154dd)) +* **hashmap2:** Update incorrect assertion (#660) ([72aaa15e](https://github.com/rust-lang/rustlings/commit/72aaa15e6ab4b72b3422f1c6356396e20a2a2bb8)) +* **info:** Fix typo (#635) ([cddc1e86](https://github.com/rust-lang/rustlings/commit/cddc1e86e7ec744ee644cc774a4887b1a0ded3e8)) +* **iterators2:** Moved errors out of tests. ([baf4ba17](https://github.com/rust-lang/rustlings/commit/baf4ba175ba6eb92989e3dd54ecbec4bedc9a863), closes [#359](https://github.com/rust-lang/rustlings/issues/359)) +* **iterators3:** Enabled iterators3.rs to run without commented out tests. ([c6712dfc](https://github.com/rust-lang/rustlings/commit/c6712dfccd1a093e590ad22bbc4f49edc417dac0)) +* **main:** Let find_exercise work with borrows ([347f30bd](https://github.com/rust-lang/rustlings/commit/347f30bd867343c5ace1097e085a1f7e356553f7)) +* **move_semantics4:** + * Remove redundant "instead" (#640) ([cc266d7d](https://github.com/rust-lang/rustlings/commit/cc266d7d80b91e79df3f61984f231b7f1587218e)) + * Small readbility improvement (#617) ([10965920](https://github.com/rust-lang/rustlings/commit/10965920fbdf8a1efc85bed869e55a1787006404)) +* **option2:** Rename uninformative variables (#675) ([b4de6594](https://github.com/rust-lang/rustlings/commit/b4de6594380636817d13c2677ec6f472a964cf43)) +* **quiz3:** Force an answer to Q2 (#672) ([0d894e6f](https://github.com/rust-lang/rustlings/commit/0d894e6ff739943901e1ae8c904582e5c2f843bd)) +* **structs:** Add 5.3 to structs/README (#652) ([6bd791f2](https://github.com/rust-lang/rustlings/commit/6bd791f2f44aa7f0ad926df767f6b1fa8f12a9a9)) +* **structs2:** correct grammar in hint (#663) ([ebdb66c7](https://github.com/rust-lang/rustlings/commit/ebdb66c7bfb6d687a14cc511a559a222e6fc5de4)) +* **structs3:** + * reword heading comment (#664) ([9f3e8c2d](https://github.com/rust-lang/rustlings/commit/9f3e8c2dde645e5264c2d2200e68842b5f47bfa3)) + * add check to prevent naive implementation of is_international ([05a753fe](https://github.com/rust-lang/rustlings/commit/05a753fe6333d36dbee5f68c21dec04eacdc75df)) +* **threads1:** line number correction ([7857b0a6](https://github.com/rust-lang/rustlings/commit/7857b0a689b0847f48d8c14cbd1865e3b812d5ca)) +* **try_from_into:** use trait objects ([2e93a588](https://github.com/rust-lang/rustlings/commit/2e93a588e0abe8badb7eafafb9e7d073c2be5df8)) + +#### Features + +* Replace clap with argh ([7928122f](https://github.com/rust-lang/rustlings/commit/7928122fcef9ca7834d988b1ec8ca0687478beeb)) +* Replace emojis when NO_EMOJI env variable present ([8d62a996](https://github.com/rust-lang/rustlings/commit/8d62a9963708dbecd9312e8bcc4b47049c72d155)) +* Added iterators5.rs exercise. ([b29ea17e](https://github.com/rust-lang/rustlings/commit/b29ea17ea94d1862114af2cf5ced0e09c197dc35)) +* **arc1:** Add more details to description and hint (#710) ([81be4044](https://github.com/rust-lang/rustlings/commit/81be40448777fa338ebced3b0bfc1b32d6370313)) +* **cli:** Improve the list command with options, and then some ([8bbe4ff1](https://github.com/rust-lang/rustlings/commit/8bbe4ff1385c5c169c90cd3ff9253f9a91daaf8e)) +* **list:** + * updated progress percentage ([1c6f7e4b](https://github.com/rust-lang/rustlings/commit/1c6f7e4b7b9b3bd36f4da2bb2b69c549cc8bd913)) + * added progress info ([c0e3daac](https://github.com/rust-lang/rustlings/commit/c0e3daacaf6850811df5bc57fa43e0f249d5cfa4)) + + + ## 4.3.0 (2020-12-29) diff --git a/Cargo.lock b/Cargo.lock index fb361569..cc8ff94a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -539,7 +539,7 @@ checksum = "24d5f089152e60f62d28b835fbff2cd2e8dc0baf1ac13343bef92ab7eed84548" [[package]] name = "rustlings" -version = "4.3.0" +version = "4.4.0" dependencies = [ "argh", "assert_cmd", diff --git a/Cargo.toml b/Cargo.toml index 397eb996..0a757040 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rustlings" -version = "4.3.0" +version = "4.4.0" authors = ["Marisa ", "Carol (Nichols || Goulding) "] edition = "2018" diff --git a/README.md b/README.md index e76a04dc..cf1de15a 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ Basically: Clone the repository, checkout to the latest tag, run `cargo install` ```bash git clone https://github.com/rust-lang/rustlings cd rustlings -git checkout tags/4.3.0 # or whatever the latest version is (find out at https://github.com/rust-lang/rustlings/releases/latest) +git checkout tags/4.4.0 # or whatever the latest version is (find out at https://github.com/rust-lang/rustlings/releases/latest) cargo install --force --path . ``` diff --git a/src/main.rs b/src/main.rs index bc1b71e4..a80ce88e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -23,7 +23,7 @@ mod run; mod verify; // In sync with crate version -const VERSION: &str = "4.3.0"; +const VERSION: &str = "4.4.0"; #[derive(FromArgs, PartialEq, Debug)] /// Rustlings is a collection of small exercises to get you used to writing and reading Rust code From c6b7ad8878d77202cd1f363a0d6b021ee48604ad Mon Sep 17 00:00:00 2001 From: Dan Stoian Date: Sat, 24 Apr 2021 18:32:13 +0300 Subject: [PATCH 195/282] updated README.md; specify need for admin rights --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cf1de15a..99b9d6e0 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ This will install Rustlings and give you access to the `rustlings` command. Run ## Windows -In PowerShell, set `ExecutionPolicy` to `RemoteSigned`: +In PowerShell (Run as Administrator), set `ExecutionPolicy` to `RemoteSigned`: ```ps Set-ExecutionPolicy RemoteSigned From 4f7dbbd2c31b49d0a34f28ae4d4ccf8210289754 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Sat, 24 Apr 2021 15:36:38 +0000 Subject: [PATCH 196/282] docs: update README.md [skip ci] --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 99b9d6e0..8ca25bae 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -[![All Contributors](https://img.shields.io/badge/all_contributors-90-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-91-orange.svg?style=flat-square)](#contributors-) # rustlings πŸ¦€β€οΈ @@ -278,6 +278,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Shao Yang Hong

πŸ–‹
Brandon Macer

πŸ–‹ +
Stoian Dan

πŸ–‹ From 3a9ec4192dc7584a56999d70b533ec18a03a096c Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Sat, 24 Apr 2021 15:36:39 +0000 Subject: [PATCH 197/282] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 2820d18a..2f209713 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -838,6 +838,15 @@ "contributions": [ "content" ] + }, + { + "login": "stoiandan", + "name": "Stoian Dan", + "avatar_url": "https://avatars.githubusercontent.com/u/10388612?v=4", + "profile": "https://github.com/stoiandan", + "contributions": [ + "content" + ] } ], "contributorsPerLine": 8, From 7f0d2c2bf011838d77fc05f111aacf2b0a663f5c Mon Sep 17 00:00:00 2001 From: apogeeoak <59737221+apogeeoak@users.noreply.github.com> Date: Sat, 24 Apr 2021 12:42:06 -0400 Subject: [PATCH 198/282] chore(iterators5): Minor formatting improvements. --- exercises/standard_library_types/iterators5.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/exercises/standard_library_types/iterators5.rs b/exercises/standard_library_types/iterators5.rs index 2d97bd46..6e246b4c 100644 --- a/exercises/standard_library_types/iterators5.rs +++ b/exercises/standard_library_types/iterators5.rs @@ -1,5 +1,4 @@ // iterators5.rs - // Let's define a simple model to track Rustlings exercise progress. Progress // will be modelled using a hash map. The name of the exercise is the key and // the progress is the value. Two counting functions were created to count the @@ -7,8 +6,7 @@ // imperative style for loops. Recreate this counting functionality using // iterators. Only the two iterator methods (count_iterator and // count_collection_iterator) need to be modified. -// Execute `rustlings hint -// iterators5` for hints. +// Execute `rustlings hint iterators5` for hints. // // Make the code compile and the tests pass. From 650b1dee541d3ad789c4ac6d461045e7c592b396 Mon Sep 17 00:00:00 2001 From: Maarten Tibau Date: Sun, 25 Apr 2021 17:49:46 +0200 Subject: [PATCH 199/282] chore: Update quiz1.rs add explicit test for 40 --- exercises/quiz1.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/exercises/quiz1.rs b/exercises/quiz1.rs index 5c5c355d..2bb2c24a 100644 --- a/exercises/quiz1.rs +++ b/exercises/quiz1.rs @@ -16,8 +16,10 @@ #[test] fn verify_test() { let price1 = calculate_apple_price(35); - let price2 = calculate_apple_price(65); + let price2 = calculate_apple_price(40); + let price3 = calculate_apple_price(65); assert_eq!(70, price1); - assert_eq!(65, price2); + assert_eq!(80, price2); + assert_eq!(65, price3); } From 166a53946cf79d01f0ae670d7778f9f7221b7cba Mon Sep 17 00:00:00 2001 From: Martin HART <82845873+martinhartxyz@users.noreply.github.com> Date: Tue, 27 Apr 2021 20:22:13 +0200 Subject: [PATCH 200/282] Correct small typo in exercises/conversions/from_str.rs --- exercises/conversions/from_str.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/conversions/from_str.rs b/exercises/conversions/from_str.rs index 4beebacd..93a5299a 100644 --- a/exercises/conversions/from_str.rs +++ b/exercises/conversions/from_str.rs @@ -20,7 +20,7 @@ struct Person { // 4. Extract the first element from the split operation and use it as the name // 5. Extract the other element from the split operation and parse it into a `usize` as the age // with something like `"4".parse::()` -// 5. If while extracting the name and the age something goes wrong, an error should be returned +// 6. If while extracting the name and the age something goes wrong, an error should be returned // If everything goes well, then return a Result of a Person object impl FromStr for Person { From 86cc85295ae36948963ae52882e285d7e3e29323 Mon Sep 17 00:00:00 2001 From: Martin HART <82845873+martinhartxyz@users.noreply.github.com> Date: Tue, 27 Apr 2021 20:22:13 +0200 Subject: [PATCH 201/282] fix: Correct small typo in exercises/conversions/from_str.rs --- exercises/conversions/from_str.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/conversions/from_str.rs b/exercises/conversions/from_str.rs index 4beebacd..93a5299a 100644 --- a/exercises/conversions/from_str.rs +++ b/exercises/conversions/from_str.rs @@ -20,7 +20,7 @@ struct Person { // 4. Extract the first element from the split operation and use it as the name // 5. Extract the other element from the split operation and parse it into a `usize` as the age // with something like `"4".parse::()` -// 5. If while extracting the name and the age something goes wrong, an error should be returned +// 6. If while extracting the name and the age something goes wrong, an error should be returned // If everything goes well, then return a Result of a Person object impl FromStr for Person { From 9569c9a9e72fb0ff792437207a579930cea8f9fb Mon Sep 17 00:00:00 2001 From: Pi Delport Date: Thu, 29 Apr 2021 23:31:26 +0200 Subject: [PATCH 202/282] style(standard_library_types): stray line break --- exercises/standard_library_types/iterators5.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/exercises/standard_library_types/iterators5.rs b/exercises/standard_library_types/iterators5.rs index 2d97bd46..d8d44537 100644 --- a/exercises/standard_library_types/iterators5.rs +++ b/exercises/standard_library_types/iterators5.rs @@ -7,8 +7,7 @@ // imperative style for loops. Recreate this counting functionality using // iterators. Only the two iterator methods (count_iterator and // count_collection_iterator) need to be modified. -// Execute `rustlings hint -// iterators5` for hints. +// Execute `rustlings hint iterators5` for hints. // // Make the code compile and the tests pass. From 404f3ef465f15916f3f9348190459b64d513b056 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Sat, 1 May 2021 10:12:42 +0000 Subject: [PATCH 203/282] docs: update README.md [skip ci] --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8ca25bae..fede6723 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -[![All Contributors](https://img.shields.io/badge/all_contributors-91-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-92-orange.svg?style=flat-square)](#contributors-) # rustlings πŸ¦€β€οΈ @@ -279,6 +279,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Shao Yang Hong

πŸ–‹
Brandon Macer

πŸ–‹
Stoian Dan

πŸ–‹ +
Pi Delport

πŸ–‹ From ce40e201f0b454822074399800886068317027aa Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Sat, 1 May 2021 10:12:43 +0000 Subject: [PATCH 204/282] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 2f209713..4627e294 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -847,6 +847,15 @@ "contributions": [ "content" ] + }, + { + "login": "PiDelport", + "name": "Pi Delport", + "avatar_url": "https://avatars.githubusercontent.com/u/630271?v=4", + "profile": "https://about.me/pjdelport", + "contributions": [ + "content" + ] } ], "contributorsPerLine": 8, From d9b69bd1a0a7a99f2c0d80933ad2eea44c8c71b2 Mon Sep 17 00:00:00 2001 From: Juan Pablo Ramirez Date: Sun, 9 May 2021 17:58:54 -0500 Subject: [PATCH 205/282] fix: remove trailing whitespace --- exercises/structs/structs3.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/structs/structs3.rs b/exercises/structs/structs3.rs index 8d8b4710..a80d0625 100644 --- a/exercises/structs/structs3.rs +++ b/exercises/structs/structs3.rs @@ -31,7 +31,7 @@ impl Package { } fn get_fees(&self, cents_per_gram: i32) -> ??? { - // Something goes here... + // Something goes here... } } From 31457940846b3844d78d4a4d2b074bc8d6aaf1eb Mon Sep 17 00:00:00 2001 From: Juan Pablo Ramirez Date: Tue, 11 May 2021 14:50:05 -0500 Subject: [PATCH 206/282] fix: add hints to generics1 and generics2 exercises --- exercises/generics/generics1.rs | 2 ++ exercises/generics/generics2.rs | 2 ++ 2 files changed, 4 insertions(+) diff --git a/exercises/generics/generics1.rs b/exercises/generics/generics1.rs index 967287ef..f93e64a0 100644 --- a/exercises/generics/generics1.rs +++ b/exercises/generics/generics1.rs @@ -1,6 +1,8 @@ // This shopping list program isn't compiling! // Use your knowledge of generics to fix it. +// Execute `rustlings hint generics1` for hints! + // I AM NOT DONE fn main() { diff --git a/exercises/generics/generics2.rs b/exercises/generics/generics2.rs index 0cb59adc..1501529c 100644 --- a/exercises/generics/generics2.rs +++ b/exercises/generics/generics2.rs @@ -1,6 +1,8 @@ // This powerful wrapper provides the ability to store a positive integer value. // Rewrite it using generics so that it supports wrapping ANY type. +// Execute `rustlings hint generics2` for hints! + // I AM NOT DONE struct Wrapper { From 4d4fa77459392acd3581c6068aa8be9a02de12fc Mon Sep 17 00:00:00 2001 From: Juan Pablo Ramirez Date: Wed, 12 May 2021 10:20:07 -0500 Subject: [PATCH 207/282] fix: remove trailing whitespaces from iterators1 --- exercises/standard_library_types/iterators1.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/exercises/standard_library_types/iterators1.rs b/exercises/standard_library_types/iterators1.rs index 3fd519d6..4606ad35 100644 --- a/exercises/standard_library_types/iterators1.rs +++ b/exercises/standard_library_types/iterators1.rs @@ -1,11 +1,11 @@ // iterators1.rs -// +// // Make me compile by filling in the `???`s // // When performing operations on elements within a collection, iterators are essential. -// This module helps you get familiar with the structure of using an iterator and +// This module helps you get familiar with the structure of using an iterator and // how to go through elements within an iterable collection. -// +// // Execute `rustlings hint iterators1` for hints :D // I AM NOT DONE From 11d2cf0d604dee3f5023c17802d69438e69fa50e Mon Sep 17 00:00:00 2001 From: Taylor Yu Date: Sat, 15 May 2021 14:01:17 -0500 Subject: [PATCH 208/282] fix(try_from_into, from_str): hints for dyn Error Add hints about how to return the correct type for functions that return `Result<_, Box`. Some feedback from Discord suggests that people run into trouble with that. --- info.toml | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/info.toml b/info.toml index 82e11952..0535a77b 100644 --- a/info.toml +++ b/info.toml @@ -893,7 +893,19 @@ 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 + +You might want to look back at the exercise errorsn (or its hints) to remind +yourself about how `Box` works. + +If you're trying to return a string as an error, note that neither `str` +nor `String` implements `error::Error`. However, there is an implementation +of `From<&str>` for `Box`. This means you can use `.into()` or +the `?` operator to convert your string into the correct error type. + +If you're having trouble with using the `?` operator to convert an error string, +recall that `?` works to convert `Err(something)` into the appropriate error +type for returning from the function.""" [[exercises]] name = "as_ref_mut" @@ -909,4 +921,7 @@ 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. -This is almost like the `try_from_into` exercise.""" +This is almost like the `try_from_into` exercise. + +If you're having trouble with returning the correct error type, see the +hints for try_from_into.""" From 399ab328d8d407265c09563aa4ef4534b2503ff2 Mon Sep 17 00:00:00 2001 From: Sateesh Date: Mon, 17 May 2021 17:40:40 +0530 Subject: [PATCH 209/282] feat: Add move_semantics5 exercise. (#746) * feat: Add move_semantics5 exercise. * feat: Add option3 exercise * Address review comments. Fix typos, sentence formatting. * Remove unwanted newline. * Address review comments: make comment inline, fix format in print. --- exercises/move_semantics/move_semantics5.rs | 14 ++++++++++++++ exercises/option/option3.rs | 19 +++++++++++++++++++ info.toml | 21 +++++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 exercises/move_semantics/move_semantics5.rs create mode 100644 exercises/option/option3.rs diff --git a/exercises/move_semantics/move_semantics5.rs b/exercises/move_semantics/move_semantics5.rs new file mode 100644 index 00000000..4f8128c7 --- /dev/null +++ b/exercises/move_semantics/move_semantics5.rs @@ -0,0 +1,14 @@ +// move_semantics5.rs +// Make me compile without adding any newlines or removing any of the lines. +// Execute `rustlings hint move_semantics5` for hints :) + +// I AM NOT DONE + +fn main() { + let mut x = 100; + let y = &mut x; + let z = &mut *y; + *y += 100; + *z += 1000; + assert_eq!(x, 1200); +} diff --git a/exercises/option/option3.rs b/exercises/option/option3.rs new file mode 100644 index 00000000..045d2acb --- /dev/null +++ b/exercises/option/option3.rs @@ -0,0 +1,19 @@ +// option3.rs +// Make me compile! Execute `rustlings hint option3` for hints + +// I AM NOT DONE + +struct Point { + x: i32, + y: i32, +} + +fn main() { + let y: Option = Some(Point { x: 100, y: 200 }); + + match y { + Some(p) => println!("Co-ordinates are {},{} ", p.x, p.y), + _ => println!("no match"), + } + y; // Fix without deleting this line. +} diff --git a/info.toml b/info.toml index 0535a77b..0e9f4282 100644 --- a/info.toml +++ b/info.toml @@ -210,6 +210,17 @@ So the end goal is to: - since we're not creating a new vec in `main` anymore, we need to create a new vec in `fill_vec`, similarly to the way we did in `main`""" +[[exercises]] +name = "move_semantics5" +path = "exercises/move_semantics/move_semantics5.rs" +mode = "compile" +hint = """ +Carefully reason about the range in which each mutable reference is in +vogue. Does updating the value of referrent (x) immediately after the +mutable reference is taken helps? Read more about 'Mutable Referenes' +in the book's section References and Borrowing': +https://doc.rust-lang.org/book/ch04-02-references-and-borrowing.html#mutable-references.""" + # PRIMITIVE TYPES [[exercises]] @@ -578,6 +589,16 @@ For example: Some(Some(variable)) = variable2 Also see Option::flatten """ +[[exercises]] +name = "option3" +path = "exercises/option/option3.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""" + [[exercises]] name = "result1" path = "exercises/error_handling/result1.rs" From cd02abc48138f9415d1d81da86524508d501a09f Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Mon, 17 May 2021 12:11:04 +0000 Subject: [PATCH 210/282] docs: update README.md [skip ci] --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index fede6723..503cf2cf 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -[![All Contributors](https://img.shields.io/badge/all_contributors-92-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-93-orange.svg?style=flat-square)](#contributors-) # rustlings πŸ¦€β€οΈ @@ -280,6 +280,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Brandon Macer

πŸ–‹
Stoian Dan

πŸ–‹
Pi Delport

πŸ–‹ +
Sateesh

πŸ’» πŸ–‹ From 72e615aa7ae36c0e0a7c82b3e22a33a04f579e3c Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Mon, 17 May 2021 12:11:05 +0000 Subject: [PATCH 211/282] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 4627e294..867f1d51 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -856,6 +856,16 @@ "contributions": [ "content" ] + }, + { + "login": "sateeshkumarb", + "name": "Sateesh ", + "avatar_url": "https://avatars.githubusercontent.com/u/429263?v=4", + "profile": "https://github.com/sateeshkumarb", + "contributions": [ + "code", + "content" + ] } ], "contributorsPerLine": 8, From 4c46e5e1a33478d6cdb5f2a08b62f5ee79e35dd9 Mon Sep 17 00:00:00 2001 From: Taylor Yu Date: Sat, 22 May 2021 21:56:14 -0500 Subject: [PATCH 212/282] chore: minor typos in move_semantics5 hints --- info.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/info.toml b/info.toml index 0e9f4282..d8e7dd59 100644 --- a/info.toml +++ b/info.toml @@ -216,8 +216,8 @@ path = "exercises/move_semantics/move_semantics5.rs" mode = "compile" hint = """ Carefully reason about the range in which each mutable reference is in -vogue. Does updating the value of referrent (x) immediately after the -mutable reference is taken helps? Read more about 'Mutable Referenes' +vogue. Does updating the value of referent (x) immediately after the +mutable reference is taken helps? Read more about 'Mutable References' in the book's section References and Borrowing': https://doc.rust-lang.org/book/ch04-02-references-and-borrowing.html#mutable-references.""" From 1b85828548f46f58b622b5e0c00f8c989f928807 Mon Sep 17 00:00:00 2001 From: Taylor Yu Date: Sat, 22 May 2021 22:09:58 -0500 Subject: [PATCH 213/282] fix: move_semantics5 hints Improve the hints for move_semantics5, as well as the explanatory comments in the code. Previously, it was not clear what possible changes were allowed. It seems that reordering the statements might be the intended solution. The previous comment about not "adding newlines" doesn't make sense, so treating it as "adding new lines" makes it more clear. --- exercises/move_semantics/move_semantics5.rs | 3 ++- info.toml | 10 +++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/exercises/move_semantics/move_semantics5.rs b/exercises/move_semantics/move_semantics5.rs index 4f8128c7..2fb7b8e8 100644 --- a/exercises/move_semantics/move_semantics5.rs +++ b/exercises/move_semantics/move_semantics5.rs @@ -1,5 +1,6 @@ // move_semantics5.rs -// Make me compile without adding any newlines or removing any of the lines. +// Make me compile without adding, removing, or changing any of the +// lines in `main()`. // Execute `rustlings hint move_semantics5` for hints :) // I AM NOT DONE diff --git a/info.toml b/info.toml index d8e7dd59..8c8f7c18 100644 --- a/info.toml +++ b/info.toml @@ -216,10 +216,14 @@ path = "exercises/move_semantics/move_semantics5.rs" mode = "compile" hint = """ Carefully reason about the range in which each mutable reference is in -vogue. Does updating the value of referent (x) immediately after the -mutable reference is taken helps? Read more about 'Mutable References' +vogue. Does it help to update the value of referent (x) immediately after +the mutable reference is taken? Read more about 'Mutable References' in the book's section References and Borrowing': -https://doc.rust-lang.org/book/ch04-02-references-and-borrowing.html#mutable-references.""" +https://doc.rust-lang.org/book/ch04-02-references-and-borrowing.html#mutable-references. + +Additional hint: +If you can't add, change, or remove any statements in `main()`, can you +reorder them in a way that lets the program compile?""" # PRIMITIVE TYPES From 91fc9e3118f4af603c9911698cc2a234725cb032 Mon Sep 17 00:00:00 2001 From: Taylor Yu Date: Sun, 6 Jun 2021 17:36:44 -0500 Subject: [PATCH 214/282] fix(iterators5): derive Clone, Copy To allow more flexibility in solutions, derive `Clone` and `Copy` for `Progress`. --- exercises/standard_library_types/iterators5.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/standard_library_types/iterators5.rs b/exercises/standard_library_types/iterators5.rs index d8d44537..765028af 100644 --- a/exercises/standard_library_types/iterators5.rs +++ b/exercises/standard_library_types/iterators5.rs @@ -15,7 +15,7 @@ use std::collections::HashMap; -#[derive(PartialEq, Eq)] +#[derive(Clone, Copy, PartialEq, Eq)] enum Progress { None, Some, From 4e079fdd0829ab271508c773aa814b21d6cff32b Mon Sep 17 00:00:00 2001 From: Taylor Yu Date: Sun, 6 Jun 2021 17:39:13 -0500 Subject: [PATCH 215/282] chore(iterators5): conciseness hint --- info.toml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/info.toml b/info.toml index 8c8f7c18..562fe42f 100644 --- a/info.toml +++ b/info.toml @@ -788,7 +788,10 @@ test count_iterator. 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 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.""" # THREADS From 50ab289da6b9eb19a7486c341b00048c516b88c0 Mon Sep 17 00:00:00 2001 From: Taylor Yu Date: Sun, 6 Jun 2021 20:14:29 -0500 Subject: [PATCH 216/282] fix: rename result1 to errors4 Also put it in the ERROR HANDLING section where it probably belongs. --- .../error_handling/{result1.rs => errors4.rs} | 4 ++-- info.toml | 20 +++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) rename exercises/error_handling/{result1.rs => errors4.rs} (88%) diff --git a/exercises/error_handling/result1.rs b/exercises/error_handling/errors4.rs similarity index 88% rename from exercises/error_handling/result1.rs rename to exercises/error_handling/errors4.rs index b978001b..0685c374 100644 --- a/exercises/error_handling/result1.rs +++ b/exercises/error_handling/errors4.rs @@ -1,5 +1,5 @@ -// result1.rs -// Make this test pass! Execute `rustlings hint result1` for hints :) +// errors4.rs +// Make this test pass! Execute `rustlings hint errors4` for hints :) // I AM NOT DONE diff --git a/info.toml b/info.toml index 8c8f7c18..55875d7e 100644 --- a/info.toml +++ b/info.toml @@ -489,6 +489,15 @@ mode = "compile" hint = """ If other functions can return a `Result`, why shouldn't `main`?""" +[[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 :)""" + [[exercises]] name = "errorsn" path = "exercises/error_handling/errorsn.rs" @@ -561,7 +570,7 @@ ReportCard struct generic, but also the correct property - you will need to chan of the struct slightly too...you can do it! """ -# OPTIONS / RESULTS +# OPTIONS [[exercises]] name = "option1" @@ -603,15 +612,6 @@ 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""" -[[exercises]] -name = "result1" -path = "exercises/error_handling/result1.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 :)""" - # TRAITS [[exercises]] From 68d3ac567cd5c23f5593c2f4df51612bca3d09a9 Mon Sep 17 00:00:00 2001 From: Taylor Yu Date: Sun, 6 Jun 2021 23:05:01 -0500 Subject: [PATCH 217/282] feature: improve error_handling exercises Add new exercises errors5 and errors6, to introduce boxed errors and custom error enums more gently. Delete errorsn, because it tried to do too much too soon. --- exercises/error_handling/errors5.rs | 53 +++++++++++++ exercises/error_handling/errors6.rs | 86 ++++++++++++++++++++ exercises/error_handling/errorsn.rs | 117 ---------------------------- info.toml | 61 ++++++++------- 4 files changed, 173 insertions(+), 144 deletions(-) create mode 100644 exercises/error_handling/errors5.rs create mode 100644 exercises/error_handling/errors6.rs delete mode 100644 exercises/error_handling/errorsn.rs diff --git a/exercises/error_handling/errors5.rs b/exercises/error_handling/errors5.rs new file mode 100644 index 00000000..1b118000 --- /dev/null +++ b/exercises/error_handling/errors5.rs @@ -0,0 +1,53 @@ +// errors5.rs + +// This program uses a completed version of the code from errors4. +// It won't compile right now! Why? +// Execute `rustlings hint errors5` for hints! + +// I AM NOT DONE + +use std::error; +use std::fmt; +use std::num::ParseIntError; + +// TODO: update the return type of `main()` to make this compile. +fn main() -> Result<(), ParseIntError> { + let pretend_user_input = "42"; + let x: i64 = pretend_user_input.parse()?; + println!("output={:?}", PositiveNonzeroInteger::new(x)?); + Ok(()) +} + +// Don't change anything below this line. + +#[derive(PartialEq, Debug)] +struct PositiveNonzeroInteger(u64); + +#[derive(PartialEq, Debug)] +enum CreationError { + Negative, + Zero, +} + +impl PositiveNonzeroInteger { + fn new(value: i64) -> Result { + match value { + x if x < 0 => Err(CreationError::Negative), + x if x == 0 => Err(CreationError::Zero), + x => Ok(PositiveNonzeroInteger(x as u64)) + } + } +} + +// This is required so that `CreationError` can implement `error::Error`. +impl fmt::Display for CreationError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let description = match *self { + CreationError::Negative => "Number is negative", + CreationError::Zero => "Number is zero", + }; + f.write_str(description) + } +} + +impl error::Error for CreationError {} diff --git a/exercises/error_handling/errors6.rs b/exercises/error_handling/errors6.rs new file mode 100644 index 00000000..cee72504 --- /dev/null +++ b/exercises/error_handling/errors6.rs @@ -0,0 +1,86 @@ +// errors6.rs + +// Using catch-all error types like `Box` isn't recommended +// for library code, where callers might want to make decisions based on the +// error content, instead of printing it out or propagating it further. Here, +// we define a custom error type to make it possible for callers to decide +// what to do next when our function returns an error. + +// Make these tests pass! Execute `rustlings hint errors6` for hints :) + +// I AM NOT DONE + +// This is a custom error type that we will be using in `parse_pos_nonzero()`. +#[derive(PartialEq, Debug)] +enum ParsePosNonzeroError { + CreationError, + ParseIntError +} + +fn parse_pos_nonzero(s: &str) + -> Result +{ + // TODO: change this to return an appropriate error instead of panicking + // when `parse()` returns an error. + let x: i64 = s.parse().unwrap(); + PositiveNonzeroInteger::new(x) + .or(Err(ParsePosNonzeroError::CreationError)) +} + +// Don't change anything below this line. + +#[derive(PartialEq, Debug)] +struct PositiveNonzeroInteger(u64); + +#[derive(PartialEq, Debug)] +enum CreationError { + Negative, + Zero, +} + +impl PositiveNonzeroInteger { + fn new(value: i64) -> Result { + match value { + x if x < 0 => Err(CreationError::Negative), + x if x == 0 => Err(CreationError::Zero), + x => Ok(PositiveNonzeroInteger(x as u64)) + } + } +} + +#[cfg(test)] +mod test { + use super::*; + + #[test] + fn test_parse_error() { + assert_eq!( + parse_pos_nonzero("not a number"), + Err(ParsePosNonzeroError::ParseIntError) + ); + } + + #[test] + fn test_negative() { + assert_eq!( + parse_pos_nonzero("-555"), + Err(ParsePosNonzeroError::CreationError) + ); + } + + #[test] + fn test_zero() { + assert_eq!( + parse_pos_nonzero("0"), + Err(ParsePosNonzeroError::CreationError) + ); + } + + #[test] + fn test_positive() { + assert_eq!( + parse_pos_nonzero("42"), + Ok(PositiveNonzeroInteger(42)) + ); + } +} diff --git a/exercises/error_handling/errorsn.rs b/exercises/error_handling/errorsn.rs deleted file mode 100644 index 5fe212bf..00000000 --- a/exercises/error_handling/errorsn.rs +++ /dev/null @@ -1,117 +0,0 @@ -// errorsn.rs -// This is a bigger error exercise than the previous ones! -// You can do it! :) -// -// Edit the `read_and_validate` function ONLY. Don't create any Errors -// that do not already exist. -// -// So many things could go wrong! -// -// - Reading from stdin could produce an io::Error -// - Parsing the input could produce a num::ParseIntError -// - Validating the input could produce a CreationError (defined below) -// -// How can we lump these errors into one general error? That is, what -// type goes where the question marks are, and how do we return -// that type from the body of read_and_validate? -// -// Execute `rustlings hint errorsn` for hints :) - -// I AM NOT DONE - -use std::error; -use std::fmt; -use std::io; - -// PositiveNonzeroInteger is a struct defined below the tests. -fn read_and_validate(b: &mut dyn io::BufRead) -> Result { - let mut line = String::new(); - b.read_line(&mut line); - let num: i64 = line.trim().parse(); - let answer = PositiveNonzeroInteger::new(num); - answer -} - -// -// Nothing below this needs to be modified -// - -// This is a test helper function that turns a &str into a BufReader. -fn test_with_str(s: &str) -> Result> { - let mut b = io::BufReader::new(s.as_bytes()); - read_and_validate(&mut b) -} - -#[test] -fn test_success() { - let x = test_with_str("42\n"); - assert_eq!(PositiveNonzeroInteger(42), x.unwrap()); -} - -#[test] -fn test_not_num() { - let x = test_with_str("eleven billion\n"); - assert!(x.is_err()); -} - -#[test] -fn test_non_positive() { - let x = test_with_str("-40\n"); - assert!(x.is_err()); -} - -#[test] -fn test_ioerror() { - struct Broken; - impl io::Read for Broken { - fn read(&mut self, _buf: &mut [u8]) -> io::Result { - Err(io::Error::new(io::ErrorKind::BrokenPipe, "uh-oh!")) - } - } - let mut b = io::BufReader::new(Broken); - assert!(read_and_validate(&mut b).is_err()); - assert_eq!("uh-oh!", read_and_validate(&mut b).unwrap_err().to_string()); -} - -#[derive(PartialEq, Debug)] -struct PositiveNonzeroInteger(u64); - -impl PositiveNonzeroInteger { - fn new(value: i64) -> Result { - if value == 0 { - Err(CreationError::Zero) - } else if value < 0 { - Err(CreationError::Negative) - } else { - Ok(PositiveNonzeroInteger(value as u64)) - } - } -} - -#[test] -fn test_positive_nonzero_integer_creation() { - assert!(PositiveNonzeroInteger::new(10).is_ok()); - assert_eq!( - Err(CreationError::Negative), - PositiveNonzeroInteger::new(-10) - ); - assert_eq!(Err(CreationError::Zero), PositiveNonzeroInteger::new(0)); -} - -#[derive(PartialEq, Debug)] -enum CreationError { - Negative, - Zero, -} - -impl fmt::Display for CreationError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let description = match *self { - CreationError::Negative => "Number is negative", - CreationError::Zero => "Number is zero", - }; - f.write_str(description) - } -} - -impl error::Error for CreationError {} diff --git a/info.toml b/info.toml index 55875d7e..63eb78b0 100644 --- a/info.toml +++ b/info.toml @@ -499,42 +499,49 @@ It should be doing some checking, returning an `Err` result if those checks fail returning an `Ok` result if those checks determine that everything is... okay :)""" [[exercises]] -name = "errorsn" -path = "exercises/error_handling/errorsn.rs" -mode = "test" +name = "errors5" +path = "exercises/error_handling/errors5.rs" +mode = "compile" hint = """ -First hint: To figure out what type should go where the ??? is, take a look -at the test helper function `test_with_str`, since it returns whatever -`read_and_validate` returns and `test_with_str` has its signature fully -specified. - - -Next hint: There are three places in `read_and_validate` that we call a -function that returns a `Result` (that is, the functions might fail). -Apply the `?` operator on those calls so that we return immediately from -`read_and_validate` if those function calls fail. - +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? Another hint: under the hood, the `?` operator calls `From::from` -on the error value to convert it to a boxed trait object, a Box, -which is polymorphic-- that means that lots of different kinds of errors -can be returned from the same function because all errors act the same -since they all implement the `error::Error` trait. +on the error value to convert it to a boxed trait object, a +`Box`, which is polymorphic-- that means that lots of +different kinds of errors can be returned from the same function because +all errors act the same since they all implement the `error::Error` trait. Check out this section of the book: https://doc.rust-lang.org/book/ch09-02-recoverable-errors-with-result.html#a-shortcut-for-propagating-errors-the--operator +This exercise uses some concepts that we won't get to until later in the +course, like `Box` and the `From` trait. It's not important to understand +them in detail right now, but you can read ahead if you like. -Another another hint: Note that because the `?` operator returns -the *unwrapped* value in the `Ok` case, if we want to return a `Result` from -`read_and_validate` for *its* success case, we'll have to rewrap a value -that we got from the return value of a `?`ed call in an `Ok`-- this will -look like `Ok(something)`. +Read more about boxing errors: +https://doc.rust-lang.org/stable/rust-by-example/error/multiple_error_types/boxing_errors.html +Read more about using the `?` operator with boxed errors: +https://doc.rust-lang.org/stable/rust-by-example/error/multiple_error_types/reenter_question_mark.html +""" -Another another another hint: `Result`s must be "used", that is, you'll -get a warning if you don't handle a `Result` that you get in your -function. Read more about that in the `std::result` module docs: -https://doc.rust-lang.org/std/result/#results-must-be-used""" +[[exercises]] +name = "errors6" +path = "exercises/error_handling/errors6.rs" +mode = "test" +hint = """ +This exercise uses a completed version of `PositiveNonzeroInteger` from +the errors4. + +Below the TODO line, there is an example of using the `.or()` 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 use a `match` +expression, or maybe there's another way! + +Read more about `.or()` in the `std::result` documentation: +https://doc.rust-lang.org/std/result/enum.Result.html#method.or""" # Generics From 48ffcbd2c4cc4d936c2c7480019190f179813cc5 Mon Sep 17 00:00:00 2001 From: ZC Date: Mon, 7 Jun 2021 18:22:55 +0800 Subject: [PATCH 218/282] fix(variables5): confine the answer further let mut number = 3; can lead to a correct answer, so the comment helps to direct the users to the intended answer. --- exercises/variables/variables5.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/variables/variables5.rs b/exercises/variables/variables5.rs index da37ae99..175eebb3 100644 --- a/exercises/variables/variables5.rs +++ b/exercises/variables/variables5.rs @@ -4,7 +4,7 @@ // I AM NOT DONE fn main() { - let number = "T-H-R-E-E"; + let number = "T-H-R-E-E"; // don't change this line println!("Spell a Number : {}", number); number = 3; println!("Number plus two is : {}", number + 2); From b7ddd09fab97fc96f032bc8c0b9e1a64e5ffbcdd Mon Sep 17 00:00:00 2001 From: Taylor Yu Date: Wed, 9 Jun 2021 18:13:57 -0500 Subject: [PATCH 219/282] address review feedback Adjust error text and naming to conform with best practices. Use `map_err()` instead of `or()`. Wrap lower-level errors instead of ignoring their details. Also, don't "cheat" by bypassing the `new()` function in tests. Fix a dangling reference in the try_from_into hints. --- exercises/error_handling/errors5.rs | 4 ++-- exercises/error_handling/errors6.rs | 33 ++++++++++++++++++----------- info.toml | 21 ++++++++++-------- 3 files changed, 35 insertions(+), 23 deletions(-) diff --git a/exercises/error_handling/errors5.rs b/exercises/error_handling/errors5.rs index 1b118000..365a8691 100644 --- a/exercises/error_handling/errors5.rs +++ b/exercises/error_handling/errors5.rs @@ -43,8 +43,8 @@ impl PositiveNonzeroInteger { impl fmt::Display for CreationError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let description = match *self { - CreationError::Negative => "Number is negative", - CreationError::Zero => "Number is zero", + CreationError::Negative => "number is negative", + CreationError::Zero => "number is zero", }; f.write_str(description) } diff --git a/exercises/error_handling/errors6.rs b/exercises/error_handling/errors6.rs index cee72504..0f6b27a6 100644 --- a/exercises/error_handling/errors6.rs +++ b/exercises/error_handling/errors6.rs @@ -10,11 +10,20 @@ // I AM NOT DONE +use std::num::ParseIntError; + // This is a custom error type that we will be using in `parse_pos_nonzero()`. #[derive(PartialEq, Debug)] enum ParsePosNonzeroError { - CreationError, - ParseIntError + Creation(CreationError), + ParseInt(ParseIntError) +} + +impl ParsePosNonzeroError { + fn from_creation(err: CreationError) -> ParsePosNonzeroError { + ParsePosNonzeroError::Creation(err) + } + // TODO: add another error conversion function here. } fn parse_pos_nonzero(s: &str) @@ -24,7 +33,7 @@ fn parse_pos_nonzero(s: &str) // when `parse()` returns an error. let x: i64 = s.parse().unwrap(); PositiveNonzeroInteger::new(x) - .or(Err(ParsePosNonzeroError::CreationError)) + .map_err(ParsePosNonzeroError::from_creation) } // Don't change anything below this line. @@ -54,17 +63,18 @@ mod test { #[test] fn test_parse_error() { - assert_eq!( + // We can't construct a ParseIntError, so we have to pattern match. + assert!(matches!( parse_pos_nonzero("not a number"), - Err(ParsePosNonzeroError::ParseIntError) - ); + Err(ParsePosNonzeroError::ParseInt(_)) + )); } #[test] fn test_negative() { assert_eq!( parse_pos_nonzero("-555"), - Err(ParsePosNonzeroError::CreationError) + Err(ParsePosNonzeroError::Creation(CreationError::Negative)) ); } @@ -72,15 +82,14 @@ mod test { fn test_zero() { assert_eq!( parse_pos_nonzero("0"), - Err(ParsePosNonzeroError::CreationError) + Err(ParsePosNonzeroError::Creation(CreationError::Zero)) ); } #[test] fn test_positive() { - assert_eq!( - parse_pos_nonzero("42"), - Ok(PositiveNonzeroInteger(42)) - ); + let x = PositiveNonzeroInteger::new(42); + assert!(x.is_ok()); + assert_eq!(parse_pos_nonzero("42"), Ok(x.unwrap())); } } diff --git a/info.toml b/info.toml index 63eb78b0..76950373 100644 --- a/info.toml +++ b/info.toml @@ -532,16 +532,19 @@ path = "exercises/error_handling/errors6.rs" mode = "test" hint = """ This exercise uses a completed version of `PositiveNonzeroInteger` from -the errors4. +errors4. -Below the TODO line, there is an example of using the `.or()` 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 use a `match` -expression, or maybe there's another way! +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 +use a `match` expression, or maybe there's another way! -Read more about `.or()` in the `std::result` documentation: -https://doc.rust-lang.org/std/result/enum.Result.html#method.or""" +You can create another function inside `impl ParsePosNonzeroError` to use +with `map_err()`. + +Read more about `map_err()` in the `std::result` documentation: +https://doc.rust-lang.org/std/result/enum.Result.html#method.map_err""" # Generics @@ -927,7 +930,7 @@ 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 might want to look back at the exercise errorsn (or its hints) to remind +You might want to look back at the exercise errors5 (or its hints) to remind yourself about how `Box` works. If you're trying to return a string as an error, note that neither `str` From 75788b1148d054e24b019c6efa47662eaf88ce74 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Thu, 24 Jun 2021 12:10:23 +0000 Subject: [PATCH 220/282] docs: update README.md [skip ci] --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 503cf2cf..07e7c700 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -[![All Contributors](https://img.shields.io/badge/all_contributors-93-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-94-orange.svg?style=flat-square)](#contributors-) # rustlings πŸ¦€β€οΈ @@ -281,6 +281,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Stoian Dan

πŸ–‹
Pi Delport

πŸ–‹
Sateesh

πŸ’» πŸ–‹ +
ZC

πŸ–‹ From 73777980f1108f9362ddcf8211f0a8e9918cf996 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Thu, 24 Jun 2021 12:10:24 +0000 Subject: [PATCH 221/282] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 867f1d51..4e2f1efa 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -866,6 +866,15 @@ "code", "content" ] + }, + { + "login": "kayuapi", + "name": "ZC", + "avatar_url": "https://avatars.githubusercontent.com/u/10304328?v=4", + "profile": "https://github.com/kayuapi", + "contributions": [ + "content" + ] } ], "contributorsPerLine": 8, From d91044f3a24f65e27321d544a9ff7895919fa63e Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Thu, 24 Jun 2021 12:17:31 +0000 Subject: [PATCH 222/282] docs: update README.md [skip ci] --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 07e7c700..2f21b990 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -[![All Contributors](https://img.shields.io/badge/all_contributors-94-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-95-orange.svg?style=flat-square)](#contributors-) # rustlings πŸ¦€β€οΈ @@ -282,6 +282,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Pi Delport

πŸ–‹
Sateesh

πŸ’» πŸ–‹
ZC

πŸ–‹ +
hyperparabolic

πŸ’» From fadade85920268fa37092ba42adb0855d82478cf Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Thu, 24 Jun 2021 12:17:32 +0000 Subject: [PATCH 223/282] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 4e2f1efa..e3ddb19a 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -875,6 +875,15 @@ "contributions": [ "content" ] + }, + { + "login": "hyperparabolic", + "name": "hyperparabolic", + "avatar_url": "https://avatars.githubusercontent.com/u/12348474?v=4", + "profile": "https://github.com/hyperparabolic", + "contributions": [ + "code" + ] } ], "contributorsPerLine": 8, From 2dc93caddad43821743e4903d89b355df58d7a49 Mon Sep 17 00:00:00 2001 From: Taylor Yu Date: Thu, 24 Jun 2021 21:33:41 -0500 Subject: [PATCH 224/282] fix(from_str, try_from_into): custom error types Remove the use of trait objects as errors from `from_str` and `try_from_into`; they seem to have caused a lot of confusion in practice. (Also, it's considered best practice to use custom error types instead of boxed errors in library code.) Instead, use custom error enums, and update hints accordingly. Hints also provide some guidance about converting errors, which could be covered more completely in a future advanced errors section. Also move from_str to directly after the similar exercise `from_into`, for the sake of familiarity when solving. --- exercises/conversions/from_str.rs | 56 ++++++++++++++----- exercises/conversions/try_from_into.rs | 74 ++++++++++++++++++-------- info.toml | 53 ++++++++++-------- 3 files changed, 127 insertions(+), 56 deletions(-) diff --git a/exercises/conversions/from_str.rs b/exercises/conversions/from_str.rs index 4beebacd..6e9e699d 100644 --- a/exercises/conversions/from_str.rs +++ b/exercises/conversions/from_str.rs @@ -1,16 +1,31 @@ -// This does practically the same thing that TryFrom<&str> does. +// from_str.rs +// This is similar to from_into.rs, but this time we'll implement `FromStr` +// and return errors instead of falling back to a default value. // Additionally, upon implementing FromStr, you can use the `parse` method // on strings to generate an object of the implementor type. // You can read more about it at https://doc.rust-lang.org/std/str/trait.FromStr.html -use std::error; +use std::num::ParseIntError; use std::str::FromStr; -#[derive(Debug)] +#[derive(Debug, PartialEq)] struct Person { name: String, age: usize, } +// We will use this error type for the `FromStr` implementation. +#[derive(Debug, PartialEq)] +enum ParsePersonError { + // Empty input string + Empty, + // Incorrect number of fields + BadLen, + // Empty name field + NoName, + // Wrapped error from parse::() + ParseInt(ParseIntError), +} + // I AM NOT DONE // Steps: @@ -24,7 +39,7 @@ struct Person { // If everything goes well, then return a Result of a Person object impl FromStr for Person { - type Err = Box; + type Err = ParsePersonError; fn from_str(s: &str) -> Result { } } @@ -40,7 +55,7 @@ mod tests { #[test] fn empty_input() { - assert!("".parse::().is_err()); + assert_eq!("".parse::(), Err(ParsePersonError::Empty)); } #[test] fn good_input() { @@ -52,41 +67,56 @@ mod tests { } #[test] fn missing_age() { - assert!("John,".parse::().is_err()); + assert!(matches!( + "John,".parse::(), + Err(ParsePersonError::ParseInt(_)) + )); } #[test] fn invalid_age() { - assert!("John,twenty".parse::().is_err()); + assert!(matches!( + "John,twenty".parse::(), + Err(ParsePersonError::ParseInt(_)) + )); } #[test] fn missing_comma_and_age() { - assert!("John".parse::().is_err()); + assert_eq!("John".parse::(), Err(ParsePersonError::BadLen)); } #[test] fn missing_name() { - assert!(",1".parse::().is_err()); + assert_eq!(",1".parse::(), Err(ParsePersonError::NoName)); } #[test] fn missing_name_and_age() { - assert!(",".parse::().is_err()); + assert!(matches!( + ",".parse::(), + Err(ParsePersonError::NoName | ParsePersonError::ParseInt(_)) + )); } #[test] fn missing_name_and_invalid_age() { - assert!(",one".parse::().is_err()); + assert!(matches!( + ",one".parse::(), + Err(ParsePersonError::NoName | ParsePersonError::ParseInt(_)) + )); } #[test] fn trailing_comma() { - assert!("John,32,".parse::().is_err()); + assert_eq!("John,32,".parse::(), Err(ParsePersonError::BadLen)); } #[test] fn trailing_comma_and_some_string() { - assert!("John,32,man".parse::().is_err()); + assert_eq!( + "John,32,man".parse::(), + Err(ParsePersonError::BadLen) + ); } } diff --git a/exercises/conversions/try_from_into.rs b/exercises/conversions/try_from_into.rs index c0b5d986..b8ec4455 100644 --- a/exercises/conversions/try_from_into.rs +++ b/exercises/conversions/try_from_into.rs @@ -1,9 +1,9 @@ +// try_from_into.rs // TryFrom is a simple and safe type conversion that may fail in a controlled way under some circumstances. // Basically, this is the same as From. The main difference is that this should return a Result type // instead of the target type itself. // You can read more about it at https://doc.rust-lang.org/std/convert/trait.TryFrom.html use std::convert::{TryFrom, TryInto}; -use std::error; #[derive(Debug, PartialEq)] struct Color { @@ -12,12 +12,21 @@ struct Color { blue: u8, } +// We will use this error type for these `TryFrom` conversions. +#[derive(Debug, PartialEq)] +enum IntoColorError { + // Incorrect length of slice + BadLen, + // Integer conversion error + IntConversion, +} + // I AM NOT DONE // Your task is to complete this implementation // and return an Ok result of inner type Color. // You need to create an implementation for a tuple of three integers, -// an array of three integers and a slice of integers. +// an array of three integers, and a slice of integers. // // Note that the implementation for tuple and array will be checked at compile time, // but the slice implementation needs to check the slice length! @@ -25,20 +34,23 @@ struct Color { // Tuple implementation impl TryFrom<(i16, i16, i16)> for Color { - type Error = Box; - fn try_from(tuple: (i16, i16, i16)) -> Result {} + type Error = IntoColorError; + fn try_from(tuple: (i16, i16, i16)) -> Result { + } } // Array implementation impl TryFrom<[i16; 3]> for Color { - type Error = Box; - fn try_from(arr: [i16; 3]) -> Result {} + type Error = IntoColorError; + fn try_from(arr: [i16; 3]) -> Result { + } } // Slice implementation impl TryFrom<&[i16]> for Color { - type Error = Box; - fn try_from(slice: &[i16]) -> Result {} + type Error = IntoColorError; + fn try_from(slice: &[i16]) -> Result { + } } fn main() { @@ -46,15 +58,15 @@ fn main() { let c1 = Color::try_from((183, 65, 14)); println!("{:?}", c1); - // Since From is implemented for Color, we should be able to use Into + // Since TryFrom is implemented for Color, we should be able to use TryInto let c2: Result = [183, 65, 14].try_into(); println!("{:?}", c2); let v = vec![183, 65, 14]; - // With slice we should use `from` function + // With slice we should use `try_from` function let c3 = Color::try_from(&v[..]); println!("{:?}", c3); - // or take slice within round brackets and use Into + // or take slice within round brackets and use TryInto let c4: Result = (&v[..]).try_into(); println!("{:?}", c4); } @@ -65,15 +77,24 @@ mod tests { #[test] fn test_tuple_out_of_range_positive() { - assert!(Color::try_from((256, 1000, 10000)).is_err()); + assert_eq!( + Color::try_from((256, 1000, 10000)), + Err(IntoColorError::IntConversion) + ); } #[test] fn test_tuple_out_of_range_negative() { - assert!(Color::try_from((-1, -10, -256)).is_err()); + assert_eq!( + Color::try_from((-1, -10, -256)), + Err(IntoColorError::IntConversion) + ); } #[test] fn test_tuple_sum() { - assert!(Color::try_from((-1, 255, 255)).is_err()); + assert_eq!( + Color::try_from((-1, 255, 255)), + Err(IntoColorError::IntConversion) + ); } #[test] fn test_tuple_correct() { @@ -91,17 +112,17 @@ mod tests { #[test] fn test_array_out_of_range_positive() { let c: Result = [1000, 10000, 256].try_into(); - assert!(c.is_err()); + assert_eq!(c, Err(IntoColorError::IntConversion)); } #[test] fn test_array_out_of_range_negative() { let c: Result = [-10, -256, -1].try_into(); - assert!(c.is_err()); + assert_eq!(c, Err(IntoColorError::IntConversion)); } #[test] fn test_array_sum() { let c: Result = [-1, 255, 255].try_into(); - assert!(c.is_err()); + assert_eq!(c, Err(IntoColorError::IntConversion)); } #[test] fn test_array_correct() { @@ -119,17 +140,26 @@ mod tests { #[test] fn test_slice_out_of_range_positive() { let arr = [10000, 256, 1000]; - assert!(Color::try_from(&arr[..]).is_err()); + assert_eq!( + Color::try_from(&arr[..]), + Err(IntoColorError::IntConversion) + ); } #[test] fn test_slice_out_of_range_negative() { let arr = [-256, -1, -10]; - assert!(Color::try_from(&arr[..]).is_err()); + assert_eq!( + Color::try_from(&arr[..]), + Err(IntoColorError::IntConversion) + ); } #[test] fn test_slice_sum() { let arr = [-1, 255, 255]; - assert!(Color::try_from(&arr[..]).is_err()); + assert_eq!( + Color::try_from(&arr[..]), + Err(IntoColorError::IntConversion) + ); } #[test] fn test_slice_correct() { @@ -148,11 +178,11 @@ mod tests { #[test] fn test_slice_excess_length() { let v = vec![0, 0, 0, 0]; - assert!(Color::try_from(&v[..]).is_err()); + assert_eq!(Color::try_from(&v[..]), Err(IntoColorError::BadLen)); } #[test] fn test_slice_insufficient_length() { let v = vec![0, 0]; - assert!(Color::try_from(&v[..]).is_err()); + assert_eq!(Color::try_from(&v[..]), Err(IntoColorError::BadLen)); } } diff --git a/info.toml b/info.toml index ab4dc933..f5af8840 100644 --- a/info.toml +++ b/info.toml @@ -925,6 +925,27 @@ mode = "test" hint = """ Follow the steps provided right before the `From` implementation""" +[[exercises]] +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. + +This is almost like the `from_into` exercise, but returning errors instead +of falling back to a default value. + +Hint: Look at the test cases to see which error variants to return. + +Another hint: You can use the `map_err` method of `Result` with a function +or a closure to wrap the error from `parse::`. + +Yet another hint: If you would like to propagate errors by using the `?` +operator in your solution, you might want to look at +https://doc.rust-lang.org/stable/rust-by-example/error/multiple_error_types/reenter_question_mark.html +""" + [[exercises]] name = "try_from_into" path = "exercises/conversions/try_from_into.rs" @@ -933,17 +954,19 @@ 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 might want to look back at the exercise errors5 (or its hints) to remind -yourself about how `Box` works. +Hint: 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? -If you're trying to return a string as an error, note that neither `str` -nor `String` implements `error::Error`. However, there is an implementation -of `From<&str>` for `Box`. This means you can use `.into()` or -the `?` operator to convert your string into the correct error type. +Another hint: Look at the test cases to see which error variants to return. -If you're having trouble with using the `?` operator to convert an error string, -recall that `?` works to convert `Err(something)` into the appropriate error -type for returning from the function.""" +Yet another hint: You can use the `map_err` or `or` methods of `Result` to +convert errors. + +Yet another hint: If you would like to propagate errors by using the `?` +operator in your solution, you might want to look at +https://doc.rust-lang.org/stable/rust-by-example/error/multiple_error_types/reenter_question_mark.html + +Challenge: Can you make the `TryFrom` implementations generic over many integer types?""" [[exercises]] name = "as_ref_mut" @@ -951,15 +974,3 @@ path = "exercises/conversions/as_ref_mut.rs" mode = "test" hint = """ Add AsRef as a trait bound to the functions.""" - -[[exercises]] -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. -This is almost like the `try_from_into` exercise. - -If you're having trouble with returning the correct error type, see the -hints for try_from_into.""" From 3a4433d5a2961e3f3e613bd67459579fbc6277fa Mon Sep 17 00:00:00 2001 From: arlecchino Date: Mon, 28 Jun 2021 17:08:53 +0200 Subject: [PATCH 225/282] docs: Faster git clone command Clone only release tag without history --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2f21b990..2aa54e04 100644 --- a/README.md +++ b/README.md @@ -57,12 +57,12 @@ When you get a permission denied message then you have to exclude the directory ## Manually -Basically: Clone the repository, checkout to the latest tag, run `cargo install`. +Basically: Clone the repository at the latest tag, run `cargo install`. ```bash -git clone https://github.com/rust-lang/rustlings +# find out the latest version at https://github.com/rust-lang/rustlings/releases/latest (on edit 4.4.0) +git clone -b 4.4.0 --depth 1 https://github.com/rust-lang/rustlings cd rustlings -git checkout tags/4.4.0 # or whatever the latest version is (find out at https://github.com/rust-lang/rustlings/releases/latest) cargo install --force --path . ``` From 34ea029df8cb0af90524b9158990a56d6beb3d10 Mon Sep 17 00:00:00 2001 From: arlecchino Date: Tue, 29 Jun 2021 12:03:18 +0200 Subject: [PATCH 226/282] chore: Update hint of iterators3 `collect()` needs some hint for standard_library_types/iterators3 exercise with doc link for understanding different return types via `FromIterator`. --- info.toml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/info.toml b/info.toml index ab4dc933..dedc65db 100644 --- a/info.toml +++ b/info.toml @@ -772,7 +772,10 @@ 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 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 how +the `FromIterator` trait is used in `collect()`.""" [[exercises]] name = "iterators4" From 2e05606edca43baeeed88c693b9041442362c148 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Tue, 29 Jun 2021 10:46:40 +0000 Subject: [PATCH 227/282] docs: update README.md [skip ci] --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2aa54e04..ecb8bde7 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -[![All Contributors](https://img.shields.io/badge/all_contributors-95-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-96-orange.svg?style=flat-square)](#contributors-) # rustlings πŸ¦€β€οΈ @@ -283,6 +283,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Sateesh

πŸ’» πŸ–‹
ZC

πŸ–‹
hyperparabolic

πŸ’» +
arlecchino

πŸ“– From 3b4514b686b15949112a50f6ec49c79e08dcae38 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Tue, 29 Jun 2021 10:46:41 +0000 Subject: [PATCH 228/282] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index e3ddb19a..285584b2 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -884,6 +884,15 @@ "contributions": [ "code" ] + }, + { + "login": "kolbma", + "name": "arlecchino", + "avatar_url": "https://avatars.githubusercontent.com/u/5228369?v=4", + "profile": "https://www.net4visions.at", + "contributions": [ + "doc" + ] } ], "contributorsPerLine": 8, From a4a10987667ed5094763101fb885c9efc0e53bc3 Mon Sep 17 00:00:00 2001 From: arlecchino Date: Tue, 29 Jun 2021 13:41:16 +0200 Subject: [PATCH 229/282] Update info.toml Co-authored-by: marisa --- info.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/info.toml b/info.toml index dedc65db..e91909a6 100644 --- a/info.toml +++ b/info.toml @@ -774,7 +774,7 @@ 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. -See https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.collect how +See https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.collect for how the `FromIterator` trait is used in `collect()`.""" [[exercises]] From 9bf4c5e8df576e36a1a2e9d022dae6b7d5e5f4f8 Mon Sep 17 00:00:00 2001 From: arlecchino Date: Tue, 29 Jun 2021 20:47:32 +0200 Subject: [PATCH 230/282] chore: clippy1 hint enhancement Added some explanation and links about floating point representation and to use the clippy suggestion. (fixes #390) --- info.toml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/info.toml b/info.toml index e91909a6..afc7fdfe 100644 --- a/info.toml +++ b/info.toml @@ -902,7 +902,15 @@ name = "clippy1" path = "exercises/clippy/clippy1.rs" mode = "clippy" hint = """ -Floating point calculations are usually imprecise, so asking if two values are exactly equal is asking for trouble""" +Not every floating point value can be represented exactly in binary values in +memory. Take a look at the description of +https://doc.rust-lang.org/stable/std/primitive.f32.html +When using the binary compare operators with floating points you won't compare +the floating point values but the binary representation in memory. This is +usually not what you would like to do. +See the suggestions of the clippy warning in compile output and use the +machine epsilon value... +https://doc.rust-lang.org/stable/std/primitive.f32.html#associatedconstant.EPSILON""" [[exercises]] name = "clippy2" From d20e413a68772cd493561f2651cf244e822b7ca5 Mon Sep 17 00:00:00 2001 From: Richthofen Date: Wed, 30 Jun 2021 03:05:49 -0700 Subject: [PATCH 231/282] feat(cli): Add "next" to run the next unsolved exercise. (#785) * Add "run next" to run the next unsolved exercise. * Fix a grammar error in the message. * Update README.md with the suggested change Co-authored-by: marisa * Update the README.md for "rustlings hint next". Co-authored-by: marisa --- README.md | 12 ++++++++++++ src/main.rs | 25 ++++++++++++++++++------- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index ecb8bde7..bbaea0cf 100644 --- a/README.md +++ b/README.md @@ -97,6 +97,12 @@ In case you want to go by your own order, or want to only verify a single exerci rustlings run myExercise1 ``` +Or simply use the following command to run the next unsolved exercise in the course: + +```bash +rustlings run next +``` + In case you get stuck, you can run the following command to get a hint for your exercise: @@ -104,6 +110,12 @@ exercise: rustlings hint myExercise1 ``` +You can also get the hint for the next unsolved exercise with the following command: + +``` bash +rustlings hint next +``` + To check your progress, you can run the following command: ```bash rustlings list diff --git a/src/main.rs b/src/main.rs index a80ce88e..985fe34f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -286,13 +286,24 @@ fn spawn_watch_shell(failed_exercise_hint: &Arc>>) { } fn find_exercise<'a>(name: &str, exercises: &'a [Exercise]) -> &'a Exercise { - exercises - .iter() - .find(|e| e.name == name) - .unwrap_or_else(|| { - println!("No exercise found for '{}'!", name); - std::process::exit(1) - }) + if name.eq("next") { + exercises + .iter() + .find(|e| !e.looks_done()) + .unwrap_or_else(|| { + println!("πŸŽ‰ Congratulations! You have done all the exercises!"); + println!("πŸ”š There are no more exercises to do next!"); + std::process::exit(1) + }) + } else { + exercises + .iter() + .find(|e| e.name == name) + .unwrap_or_else(|| { + println!("No exercise found for '{}'!", name); + std::process::exit(1) + }) + } } fn watch(exercises: &[Exercise], verbose: bool) -> notify::Result<()> { From 1043a06124a0125a1d205180ec1c8e8e0166cf3c Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Wed, 30 Jun 2021 10:06:06 +0000 Subject: [PATCH 232/282] docs: update README.md [skip ci] --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index bbaea0cf..db254685 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -[![All Contributors](https://img.shields.io/badge/all_contributors-96-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-97-orange.svg?style=flat-square)](#contributors-) # rustlings πŸ¦€β€οΈ @@ -297,6 +297,9 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
hyperparabolic

πŸ’»
arlecchino

πŸ“– + +
Richthofen

πŸ’» + From 03dcb582e6c816cf6cb13e55a1d91485e5dfacc3 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Wed, 30 Jun 2021 10:06:07 +0000 Subject: [PATCH 233/282] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 285584b2..c449587a 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -893,6 +893,15 @@ "contributions": [ "doc" ] + }, + { + "login": "jazzplato", + "name": "Richthofen", + "avatar_url": "https://avatars.githubusercontent.com/u/7576730?v=4", + "profile": "https://richthofen.io/", + "contributions": [ + "code" + ] } ], "contributorsPerLine": 8, From 6a10f900b4b4f599a13892ea03603bbeac059e3b Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Mon, 5 Jul 2021 16:56:56 +0000 Subject: [PATCH 234/282] docs: update README.md [skip ci] --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d70cd55d..9f8f90f4 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -[![All Contributors](https://img.shields.io/badge/all_contributors-97-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-98-orange.svg?style=flat-square)](#contributors-) # rustlings πŸ¦€β€οΈ @@ -299,6 +299,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Richthofen

πŸ’» +
Ivan Nerazumov

πŸ“– From 91d86a1de960c7efabff21e192f415592e517540 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Mon, 5 Jul 2021 16:56:57 +0000 Subject: [PATCH 235/282] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index c449587a..a441a6af 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -902,6 +902,15 @@ "contributions": [ "code" ] + }, + { + "login": "cseltol", + "name": "Ivan Nerazumov", + "avatar_url": "https://avatars.githubusercontent.com/u/64264529?v=4", + "profile": "https://github.com/cseltol", + "contributions": [ + "doc" + ] } ], "contributorsPerLine": 8, From e422ab150738f578c4dc2560687a1e7214924d31 Mon Sep 17 00:00:00 2001 From: Laura Lindzey Date: Mon, 5 Jul 2021 23:07:34 -0700 Subject: [PATCH 236/282] docs: Update exercise to chapter mapping for HashMap --- exercises/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/README.md b/exercises/README.md index 0c715247..eebbd0bb 100644 --- a/exercises/README.md +++ b/exercises/README.md @@ -10,7 +10,7 @@ | structs | Β§5.1 | | enums | Β§6 | | modules | Β§7.2 | -| collections | Β§8.1 | +| collections | Β§8.1, Β§8.3 | | strings | Β§8.2 | | error_handling | Β§9 | | generics | Β§10 | From 8774e47dc34c8a7929a8b7d7504999028935ff6e Mon Sep 17 00:00:00 2001 From: lauralindzey <65185744+lauralindzey@users.noreply.github.com> Date: Tue, 6 Jul 2021 01:31:27 -0700 Subject: [PATCH 237/282] docs: Update collections README with HashMap link --- exercises/collections/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/exercises/collections/README.md b/exercises/collections/README.md index 0291bc87..b6d62acb 100644 --- a/exercises/collections/README.md +++ b/exercises/collections/README.md @@ -20,3 +20,4 @@ structures that are used very often in Rust programs: ## Further information - [Storing Lists of Values with Vectors](https://doc.rust-lang.org/stable/book/ch08-01-vectors.html) +- [Storing Keys with Associated Values in Hash Maps](https://doc.rust-lang.org/book/ch08-03-hash-maps.html) From b017579577dccce491a5f6fefd4515ac8f7d43bd Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Wed, 7 Jul 2021 20:17:03 +0000 Subject: [PATCH 238/282] docs: update README.md [skip ci] --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9f8f90f4..d7eef8d3 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -[![All Contributors](https://img.shields.io/badge/all_contributors-98-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-99-orange.svg?style=flat-square)](#contributors-) # rustlings πŸ¦€β€οΈ @@ -300,6 +300,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Richthofen

πŸ’»
Ivan Nerazumov

πŸ“– +
lauralindzey

πŸ“– From b438049c393d78fa65ea53468dc8f6093610ca8f Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Wed, 7 Jul 2021 20:17:04 +0000 Subject: [PATCH 239/282] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index a441a6af..fca0d0d1 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -911,6 +911,15 @@ "contributions": [ "doc" ] + }, + { + "login": "lauralindzey", + "name": "lauralindzey", + "avatar_url": "https://avatars.githubusercontent.com/u/65185744?v=4", + "profile": "https://github.com/lauralindzey", + "contributions": [ + "doc" + ] } ], "contributorsPerLine": 8, From d876649616cc8a8dd5f539f8bc1a5434b960b1e9 Mon Sep 17 00:00:00 2001 From: Rakshit Sinha Date: Wed, 7 Jul 2021 13:18:33 -0700 Subject: [PATCH 240/282] fix(quiz1): Updated question description (#794) Co-authored-by: Rakshit Sinha --- exercises/quiz1.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/quiz1.rs b/exercises/quiz1.rs index 2bb2c24a..3af1293d 100644 --- a/exercises/quiz1.rs +++ b/exercises/quiz1.rs @@ -5,7 +5,7 @@ // Mary is buying apples. One apple usually costs 2 Rustbucks, but if you buy // more than 40 at once, each apple only costs 1! Write a function that calculates -// the price of an order of apples given the order amount. No hints this time! +// the price of an order of apples given the quantity bought. No hints this time! // I AM NOT DONE From 23f700dc2375787fe8c79f4e191fb9e6aa3b2ef2 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Wed, 7 Jul 2021 20:19:47 +0000 Subject: [PATCH 241/282] docs: update README.md [skip ci] --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d7eef8d3..5497944d 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -[![All Contributors](https://img.shields.io/badge/all_contributors-99-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-100-orange.svg?style=flat-square)](#contributors-) # rustlings πŸ¦€β€οΈ @@ -301,6 +301,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Richthofen

πŸ’»
Ivan Nerazumov

πŸ“–
lauralindzey

πŸ“– +
Rakshit Sinha

πŸ–‹ From 33fa274bbfa85d817a39562b0461f8d42f1418c1 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Wed, 7 Jul 2021 20:19:48 +0000 Subject: [PATCH 242/282] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index fca0d0d1..85c66703 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -920,6 +920,15 @@ "contributions": [ "doc" ] + }, + { + "login": "sinharaksh1t", + "name": "Rakshit Sinha", + "avatar_url": "https://avatars.githubusercontent.com/u/28585848?v=4", + "profile": "https://github.com/sinharaksh1t", + "contributions": [ + "content" + ] } ], "contributorsPerLine": 8, From ba087ce64a35c93e40689d258f6dfde538b9ca22 Mon Sep 17 00:00:00 2001 From: ana Date: Wed, 7 Jul 2021 22:23:52 +0200 Subject: [PATCH 243/282] release: 4.5.0 Signed-off-by: ana --- CHANGELOG.md | 24 ++++++++++++++++++++++++ Cargo.lock | 2 +- Cargo.toml | 4 ++-- README.md | 4 ++-- src/main.rs | 2 +- 5 files changed, 30 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1686bdd6..67b8cdc3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,27 @@ + +## 4.5.0 (2021-07-07) + + +#### Features + +* Add move_semantics5 exercise. (#746) ([399ab328](https://github.com/rust-lang/rustlings/commit/399ab328d8d407265c09563aa4ef4534b2503ff2)) +* **cli:** Add "next" to run the next unsolved exercise. (#785) ([d20e413a](https://github.com/rust-lang/rustlings/commit/d20e413a68772cd493561f2651cf244e822b7ca5)) + +#### Bug Fixes + +* rename result1 to errors4 ([50ab289d](https://github.com/rust-lang/rustlings/commit/50ab289da6b9eb19a7486c341b00048c516b88c0)) +* move_semantics5 hints ([1b858285](https://github.com/rust-lang/rustlings/commit/1b85828548f46f58b622b5e0c00f8c989f928807)) +* remove trailing whitespaces from iterators1 ([4d4fa774](https://github.com/rust-lang/rustlings/commit/4d4fa77459392acd3581c6068aa8be9a02de12fc)) +* add hints to generics1 and generics2 exercises ([31457940](https://github.com/rust-lang/rustlings/commit/31457940846b3844d78d4a4d2b074bc8d6aaf1eb)) +* remove trailing whitespace ([d9b69bd1](https://github.com/rust-lang/rustlings/commit/d9b69bd1a0a7a99f2c0d80933ad2eea44c8c71b2)) +* **installation:** first PowerShell command ([aa9a943d](https://github.com/rust-lang/rustlings/commit/aa9a943ddf3ae260782e73c26bcc9db60e5894b6)) +* **iterators5:** derive Clone, Copy ([91fc9e31](https://github.com/rust-lang/rustlings/commit/91fc9e3118f4af603c9911698cc2a234725cb032)) +* **quiz1:** Updated question description (#794) ([d8766496](https://github.com/rust-lang/rustlings/commit/d876649616cc8a8dd5f539f8bc1a5434b960b1e9)) +* **try_from_into, from_str:** hints for dyn Error ([11d2cf0d](https://github.com/rust-lang/rustlings/commit/11d2cf0d604dee3f5023c17802d69438e69fa50e)) +* **variables5:** confine the answer further ([48ffcbd2](https://github.com/rust-lang/rustlings/commit/48ffcbd2c4cc4d936c2c7480019190f179813cc5)) + + + ## 4.4.0 (2021-04-24) diff --git a/Cargo.lock b/Cargo.lock index cc8ff94a..d291c169 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -539,7 +539,7 @@ checksum = "24d5f089152e60f62d28b835fbff2cd2e8dc0baf1ac13343bef92ab7eed84548" [[package]] name = "rustlings" -version = "4.4.0" +version = "4.5.0" dependencies = [ "argh", "assert_cmd", diff --git a/Cargo.toml b/Cargo.toml index 0a757040..615a09c3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustlings" -version = "4.4.0" -authors = ["Marisa ", "Carol (Nichols || Goulding) "] +version = "4.5.0" +authors = ["anastasie ", "Carol (Nichols || Goulding) "] edition = "2018" [dependencies] diff --git a/README.md b/README.md index 5497944d..7313c8e1 100644 --- a/README.md +++ b/README.md @@ -60,8 +60,8 @@ When you get a permission denied message then you have to exclude the directory Basically: Clone the repository at the latest tag, run `cargo install`. ```bash -# find out the latest version at https://github.com/rust-lang/rustlings/releases/latest (on edit 4.4.0) -git clone -b 4.4.0 --depth 1 https://github.com/rust-lang/rustlings +# find out the latest version at https://github.com/rust-lang/rustlings/releases/latest (on edit 4.5.0) +git clone -b 4.5.0 --depth 1 https://github.com/rust-lang/rustlings cd rustlings cargo install --force --path . ``` diff --git a/src/main.rs b/src/main.rs index 985fe34f..c8ebc68b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -23,7 +23,7 @@ mod run; mod verify; // In sync with crate version -const VERSION: &str = "4.4.0"; +const VERSION: &str = "4.5.0"; #[derive(FromArgs, PartialEq, Debug)] /// Rustlings is a collection of small exercises to get you used to writing and reading Rust code From df25684cb79f8413915e00b5efef29369849cef1 Mon Sep 17 00:00:00 2001 From: ana Date: Thu, 29 Jul 2021 12:37:15 +0200 Subject: [PATCH 244/282] fix(move_semantics5): Clarify instructions --- exercises/move_semantics/move_semantics5.rs | 4 ++-- info.toml | 5 +---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/exercises/move_semantics/move_semantics5.rs b/exercises/move_semantics/move_semantics5.rs index 2fb7b8e8..5449e951 100644 --- a/exercises/move_semantics/move_semantics5.rs +++ b/exercises/move_semantics/move_semantics5.rs @@ -1,6 +1,6 @@ // move_semantics5.rs -// Make me compile without adding, removing, or changing any of the -// lines in `main()`. +// Make me compile only be reordering the lines in `main()`, but without +// adding, changing or removing any of them. // Execute `rustlings hint move_semantics5` for hints :) // I AM NOT DONE diff --git a/info.toml b/info.toml index afc7fdfe..d5008ede 100644 --- a/info.toml +++ b/info.toml @@ -220,10 +220,7 @@ vogue. Does it help to update the value of referent (x) immediately after the mutable reference is taken? Read more about 'Mutable References' in the book's section References and Borrowing': https://doc.rust-lang.org/book/ch04-02-references-and-borrowing.html#mutable-references. - -Additional hint: -If you can't add, change, or remove any statements in `main()`, can you -reorder them in a way that lets the program compile?""" +""" # PRIMITIVE TYPES From 03131a3d35d9842598150f9da817f7cc26e2669a Mon Sep 17 00:00:00 2001 From: Damian <54457902+dbednar230@users.noreply.github.com> Date: Tue, 24 Aug 2021 03:48:51 -0500 Subject: [PATCH 245/282] fix(quiz1): Fix inconsistent wording (#826) The second test expects the function to return 80 when there is an order of 40 apples, but the current wording implies returning 40 will pass as well --- exercises/quiz1.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/quiz1.rs b/exercises/quiz1.rs index 3af1293d..985cd97c 100644 --- a/exercises/quiz1.rs +++ b/exercises/quiz1.rs @@ -4,7 +4,7 @@ // - Functions // Mary is buying apples. One apple usually costs 2 Rustbucks, but if you buy -// more than 40 at once, each apple only costs 1! Write a function that calculates +// 40 or more at once, each apple only costs 1! Write a function that calculates // the price of an order of apples given the quantity bought. No hints this time! // I AM NOT DONE From ba8f97f4188e516102852cf2b595774b3b0fb0bc Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Tue, 24 Aug 2021 08:49:23 +0000 Subject: [PATCH 246/282] docs: update README.md [skip ci] --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7313c8e1..6ae6979e 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -[![All Contributors](https://img.shields.io/badge/all_contributors-100-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-101-orange.svg?style=flat-square)](#contributors-) # rustlings πŸ¦€β€οΈ @@ -302,6 +302,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Ivan Nerazumov

πŸ“–
lauralindzey

πŸ“–
Rakshit Sinha

πŸ–‹ +
Damian

πŸ–‹ From 380587f12024a4d62c254d6e1cb08e1ec488caea Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Tue, 24 Aug 2021 08:49:24 +0000 Subject: [PATCH 247/282] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 85c66703..22df6a56 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -929,6 +929,15 @@ "contributions": [ "content" ] + }, + { + "login": "dbednar230", + "name": "Damian", + "avatar_url": "https://avatars.githubusercontent.com/u/54457902?v=4", + "profile": "https://github.com/dbednar230", + "contributions": [ + "content" + ] } ], "contributorsPerLine": 8, From 1cd9328a5872f1d6a95b02824e1af33a423c047a Mon Sep 17 00:00:00 2001 From: Ben Armstead Date: Tue, 24 Aug 2021 12:06:30 +0000 Subject: [PATCH 248/282] fix(cli): remove unnecessary borrows (#829) * Update dependencies * Format better and remove unnecessary borrows --- Cargo.lock | 114 ++++++++++++++++++++++++------------------------ src/exercise.rs | 2 +- src/main.rs | 2 +- src/verify.rs | 16 +++---- 4 files changed, 68 insertions(+), 66 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d291c169..57b211be 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,19 +1,21 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +version = 3 + [[package]] name = "aho-corasick" -version = "0.7.15" +version = "0.7.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7404febffaa47dac81aa44dba71523c9d069b1bdc50a77db41195149e17f68e5" +checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" dependencies = [ "memchr", ] [[package]] name = "argh" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91792f088f87cdc7a2cfb1d617fa5ea18d7f1dc22ef0e1b5f82f3157cdc522be" +checksum = "2e7317a549bc17c5278d9e72bb6e62c6aa801ac2567048e39ebc1c194249323e" dependencies = [ "argh_derive", "argh_shared", @@ -21,9 +23,9 @@ dependencies = [ [[package]] name = "argh_derive" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4eb0c0c120ad477412dc95a4ce31e38f2113e46bd13511253f79196ca68b067" +checksum = "60949c42375351e9442e354434b0cba2ac402c1237edf673cac3a4bf983b8d3c" dependencies = [ "argh_shared", "heck", @@ -34,9 +36,9 @@ dependencies = [ [[package]] name = "argh_shared" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "781f336cc9826dbaddb9754cb5db61e64cab4f69668bd19dcc4a0394a86f4cb1" +checksum = "8a61eb019cb8f415d162cb9f12130ee6bbe9168b7d953c17f4ad049e4051ca00" [[package]] name = "assert_cmd" @@ -69,9 +71,9 @@ checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" [[package]] name = "bitflags" -version = "1.2.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "cfg-if" @@ -156,9 +158,9 @@ dependencies = [ [[package]] name = "filetime" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d34cfa13a63ae058bfa601fe9e313bbdb3746427c1459185464ce0fcf62e1e8" +checksum = "975ccf83d8d9d0d84682850a38c8169027be83368805971cc4f238c2b245bc98" dependencies = [ "cfg-if 1.0.0", "libc", @@ -218,18 +220,18 @@ checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" [[package]] name = "heck" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cbf45460356b7deeb5e3415b5563308c0a9b057c85e12b06ad551f98d0a6ac" +checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" dependencies = [ "unicode-segmentation", ] [[package]] name = "hermit-abi" -version = "0.1.18" +version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "322f4de77956e22ed0e5032c359a0f1273f1f7f0d79bfa3b8ffbc730d7fbcc5c" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" dependencies = [ "libc", ] @@ -269,9 +271,9 @@ dependencies = [ [[package]] name = "instant" -version = "0.1.9" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61124eeebbd69b8190558df225adf7e4caafce0d743919e5d6b19652314ec5ec" +checksum = "bee0328b1209d157ef001c94dd85b4f8f64139adb0eac2659f4b08382b2f474d" dependencies = [ "cfg-if 1.0.0", ] @@ -287,9 +289,9 @@ dependencies = [ [[package]] name = "itoa" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" +checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" [[package]] name = "kernel32-sys" @@ -315,15 +317,15 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "libc" -version = "0.2.93" +version = "0.2.100" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9385f66bf6105b241aa65a61cb923ef20efc665cb9f9bb50ac2f0c4b7f378d41" +checksum = "a1fa8cddc8fbbee11227ef194b5317ed014b8acbf15139bd716a18ad3fe99ec5" [[package]] name = "lock_api" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a3c91c24eae6777794bb1997ad98bbb87daf92890acab859f7eaa4320333176" +checksum = "0382880606dff6d15c9476c416d18690b72742aa7b605bb6dd6ec9030fbf07eb" dependencies = [ "scopeguard", ] @@ -339,9 +341,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.3.4" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" +checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" [[package]] name = "mio" @@ -405,9 +407,9 @@ checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be" [[package]] name = "notify" -version = "4.0.16" +version = "4.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2599080e87c9bd051ddb11b10074f4da7b1223298df65d4c2ec5bcf309af1533" +checksum = "ae03c8c853dba7bfd23e571ff0cff7bc9dceb40a4cd684cd1681824183f45257" dependencies = [ "bitflags", "filetime", @@ -466,9 +468,9 @@ dependencies = [ [[package]] name = "predicates" -version = "1.0.7" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eeb433456c1a57cc93554dea3ce40b4c19c4057e41c55d4a0f3d84ea71c325aa" +checksum = "f49cfaf7fdaa3bfacc6fa3e7054e65148878354a5cfddcf661df4c851f8021df" dependencies = [ "difference", "float-cmp", @@ -485,9 +487,9 @@ checksum = "57e35a3326b75e49aa85f5dc6ec15b41108cf5aee58eabb1f274dd18b73c2451" [[package]] name = "predicates-tree" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15f553275e5721409451eb85e15fd9a860a6e5ab4496eb215987502b5f5391f2" +checksum = "d7dd0fd014130206c9352efbdc92be592751b2b9274dff685348341082c6ea3d" dependencies = [ "predicates-core", "treeline", @@ -495,9 +497,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.26" +version = "1.0.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a152013215dca273577e18d2bf00fa862b89b24169fb78c4c95aeb07992c9cec" +checksum = "5c7ed8b8c7b886ea3ed7dde405212185f423ab44682667c8c6dd14aa1d9f6612" dependencies = [ "unicode-xid", ] @@ -513,18 +515,18 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.2.6" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8270314b5ccceb518e7e578952f0b72b88222d02e8f77f5ecf7abbb673539041" +checksum = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff" dependencies = [ "bitflags", ] [[package]] name = "regex" -version = "1.4.6" +version = "1.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a26af418b574bd56588335b3a3659a65725d4e636eb1016c2f9e3b38c7cc759" +checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461" dependencies = [ "aho-corasick", "memchr", @@ -533,9 +535,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.23" +version = "0.6.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d5f089152e60f62d28b835fbff2cd2e8dc0baf1ac13343bef92ab7eed84548" +checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" [[package]] name = "rustlings" @@ -576,18 +578,18 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "serde" -version = "1.0.125" +version = "1.0.129" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "558dc50e1a5a5fa7112ca2ce4effcb321b0300c0d4ccf0776a9f60cd89031171" +checksum = "d1f72836d2aa753853178eda473a3b9d8e4eefdaf20523b919677e6de489f8f1" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.125" +version = "1.0.129" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b093b7a2bb58203b5da3056c05b4ec1fed827dcfdb37347a8841695263b3d06d" +checksum = "e57ae87ad533d9a56427558b516d0adac283614e347abf85b0dc0cbbf0a249f3" dependencies = [ "proc-macro2", "quote", @@ -596,9 +598,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.64" +version = "1.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "799e97dc9fdae36a5c8b8f2cae9ce2ee9fdce2058c57a93e6099d919fd982f79" +checksum = "336b10da19a12ad094b59d870ebde26a45402e5b470add4b5fd03c5048a32127" dependencies = [ "itoa", "ryu", @@ -607,9 +609,9 @@ dependencies = [ [[package]] name = "slab" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f173ac3d1a7e3b28003f40de0b5ce7fe2710f9b9dc3fc38664cebee46b3b6527" +checksum = "c307a32c1c5c437f38c7fd45d753050587732ba8628319fbdf12a7e289ccc590" [[package]] name = "smallvec" @@ -619,9 +621,9 @@ checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" [[package]] name = "syn" -version = "1.0.70" +version = "1.0.75" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9505f307c872bab8eb46f77ae357c8eba1fdacead58ee5a850116b1d7f82883" +checksum = "b7f58f7e8eaa0009c5fec437aabf511bd9933e4b2d7407bd05273c01a8906ea7" dependencies = [ "proc-macro2", "quote", @@ -630,9 +632,9 @@ dependencies = [ [[package]] name = "terminal_size" -version = "0.1.16" +version = "0.1.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86ca8ced750734db02076f44132d802af0b33b09942331f4459dde8636fd2406" +checksum = "633c1a546cee861a1a6d0dc69ebeca693bf4296661ba7852b9d21d159e0506df" dependencies = [ "libc", "winapi 0.3.9", @@ -664,9 +666,9 @@ checksum = "a7f741b240f1a48843f9b8e0444fb55fb2a4ff67293b50a9179dfd5ea67f8d41" [[package]] name = "unicode-segmentation" -version = "1.7.1" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb0d2e7be6ae3a5fa87eed5fb451aff96f2573d2694942e40543ae0bbe19c796" +checksum = "8895849a949e7845e06bd6dc1aa51731a103c42707010a5b591c0038fb73385b" [[package]] name = "unicode-width" @@ -676,9 +678,9 @@ checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" [[package]] name = "unicode-xid" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" +checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" [[package]] name = "walkdir" diff --git a/src/exercise.rs b/src/exercise.rs index d934cfd3..53457ace 100644 --- a/src/exercise.rs +++ b/src/exercise.rs @@ -162,7 +162,7 @@ path = "{}.rs""#, if cmd.status.success() { Ok(CompiledExercise { - exercise: &self, + exercise: self, _handle: FileHandle, }) } else { diff --git a/src/main.rs b/src/main.rs index c8ebc68b..1e343478 100644 --- a/src/main.rs +++ b/src/main.rs @@ -203,7 +203,7 @@ fn main() { Subcommands::Run(subargs) => { let exercise = find_exercise(&subargs.name, &exercises); - run(&exercise, verbose).unwrap_or_else(|_| std::process::exit(1)); + run(exercise, verbose).unwrap_or_else(|_| std::process::exit(1)); } Subcommands::Hint(subargs) => { diff --git a/src/verify.rs b/src/verify.rs index b98598a8..fd59fa51 100644 --- a/src/verify.rs +++ b/src/verify.rs @@ -14,9 +14,9 @@ pub fn verify<'a>( ) -> Result<(), &'a Exercise> { for exercise in start_at { let compile_result = match exercise.mode { - Mode::Test => compile_and_test(&exercise, RunMode::Interactive, verbose), - Mode::Compile => compile_and_run_interactively(&exercise), - Mode::Clippy => compile_only(&exercise), + Mode::Test => compile_and_test(exercise, RunMode::Interactive, verbose), + Mode::Compile => compile_and_run_interactively(exercise), + Mode::Clippy => compile_only(exercise), }; if !compile_result.unwrap_or(false) { return Err(exercise); @@ -42,11 +42,11 @@ fn compile_only(exercise: &Exercise) -> Result { progress_bar.set_message(format!("Compiling {}...", exercise).as_str()); progress_bar.enable_steady_tick(100); - let _ = compile(&exercise, &progress_bar)?; + let _ = compile(exercise, &progress_bar)?; progress_bar.finish_and_clear(); success!("Successfully compiled {}!", exercise); - Ok(prompt_for_completion(&exercise, None)) + Ok(prompt_for_completion(exercise, None)) } // Compile the given Exercise and run the resulting binary in an interactive mode @@ -55,7 +55,7 @@ fn compile_and_run_interactively(exercise: &Exercise) -> Result { progress_bar.set_message(format!("Compiling {}...", exercise).as_str()); progress_bar.enable_steady_tick(100); - let compilation = compile(&exercise, &progress_bar)?; + let compilation = compile(exercise, &progress_bar)?; progress_bar.set_message(format!("Running {}...", exercise).as_str()); let result = compilation.run(); @@ -73,7 +73,7 @@ fn compile_and_run_interactively(exercise: &Exercise) -> Result { success!("Successfully ran {}!", exercise); - Ok(prompt_for_completion(&exercise, Some(output.stdout))) + Ok(prompt_for_completion(exercise, Some(output.stdout))) } // Compile the given Exercise as a test harness and display @@ -94,7 +94,7 @@ fn compile_and_test(exercise: &Exercise, run_mode: RunMode, verbose: bool) -> Re } success!("Successfully tested {}", &exercise); if let RunMode::Interactive = run_mode { - Ok(prompt_for_completion(&exercise, None)) + Ok(prompt_for_completion(exercise, None)) } else { Ok(true) } From 2f0ff258b1c3780971d9b7896d8ede7848fefcdb Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Tue, 24 Aug 2021 12:06:44 +0000 Subject: [PATCH 249/282] docs: update README.md [skip ci] --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6ae6979e..c867258c 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -[![All Contributors](https://img.shields.io/badge/all_contributors-101-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-102-orange.svg?style=flat-square)](#contributors-) # rustlings πŸ¦€β€οΈ @@ -303,6 +303,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
lauralindzey

πŸ“–
Rakshit Sinha

πŸ–‹
Damian

πŸ–‹ +
Ben Armstead

πŸ’» From a64dbdcc043ae907c003ff940b43f0315283899d Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Tue, 24 Aug 2021 12:06:45 +0000 Subject: [PATCH 250/282] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 22df6a56..7816a0b8 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -938,6 +938,15 @@ "contributions": [ "content" ] + }, + { + "login": "benarmstead", + "name": "Ben Armstead", + "avatar_url": "https://avatars.githubusercontent.com/u/70973680?v=4", + "profile": "https://benarmstead.co.uk", + "contributions": [ + "code" + ] } ], "contributorsPerLine": 8, From 96fc3017642b1b4b224390320111c6e305c736a3 Mon Sep 17 00:00:00 2001 From: diannasoriel Date: Thu, 26 Aug 2021 10:30:18 +0200 Subject: [PATCH 251/282] chore(quiz1): revert wording --- exercises/quiz1.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/quiz1.rs b/exercises/quiz1.rs index 985cd97c..3af1293d 100644 --- a/exercises/quiz1.rs +++ b/exercises/quiz1.rs @@ -4,7 +4,7 @@ // - Functions // Mary is buying apples. One apple usually costs 2 Rustbucks, but if you buy -// 40 or more at once, each apple only costs 1! Write a function that calculates +// more than 40 at once, each apple only costs 1! Write a function that calculates // the price of an order of apples given the quantity bought. No hints this time! // I AM NOT DONE From dfd2fab4f33d1bf59e2e5ee03123c0c9a67a9481 Mon Sep 17 00:00:00 2001 From: anuk909 <34924662+anuk909@users.noreply.github.com> Date: Fri, 3 Sep 2021 11:41:12 +0300 Subject: [PATCH 252/282] feat(modules): update exercises, add modules3 (#822) Co-authored-by: diannasoriel --- exercises/README.md | 2 +- exercises/modules/README.md | 2 +- exercises/modules/modules1.rs | 6 ++++++ exercises/modules/modules2.rs | 8 ++++++-- exercises/modules/modules3.rs | 18 ++++++++++++++++++ info.toml | 18 +++++++++++++----- 6 files changed, 45 insertions(+), 9 deletions(-) create mode 100644 exercises/modules/modules3.rs diff --git a/exercises/README.md b/exercises/README.md index eebbd0bb..73754db5 100644 --- a/exercises/README.md +++ b/exercises/README.md @@ -9,7 +9,7 @@ | primitive_types | Β§4.3 | | structs | Β§5.1 | | enums | Β§6 | -| modules | Β§7.2 | +| modules | Β§7 | | collections | Β§8.1, Β§8.3 | | strings | Β§8.2 | | error_handling | Β§9 | diff --git a/exercises/modules/README.md b/exercises/modules/README.md index 6582b000..3dc8a482 100644 --- a/exercises/modules/README.md +++ b/exercises/modules/README.md @@ -4,4 +4,4 @@ In this section we'll give you an introduction to Rust's module system. ## Further information -- [The Module System](https://doc.rust-lang.org/book/ch07-02-defining-modules-to-control-scope-and-privacy.html) +- [The Module System](https://doc.rust-lang.org/book/ch07-00-managing-growing-projects-with-packages-crates-and-modules.html) diff --git a/exercises/modules/modules1.rs b/exercises/modules/modules1.rs index 812dfeef..1a2bd0dd 100644 --- a/exercises/modules/modules1.rs +++ b/exercises/modules/modules1.rs @@ -4,7 +4,13 @@ // I AM NOT DONE mod sausage_factory { + // Don't let anybody outside of this module see this! + fn get_secret_recipe() -> String { + String::from("Ginger") + } + fn make_sausage() { + get_secret_recipe(); println!("sausage!"); } } diff --git a/exercises/modules/modules2.rs b/exercises/modules/modules2.rs index fde439d1..687bb788 100644 --- a/exercises/modules/modules2.rs +++ b/exercises/modules/modules2.rs @@ -1,11 +1,15 @@ // modules2.rs +// You can bring module paths into scopes and provide new names for them with the +// 'use' and 'as' keywords. Fix these 'use' statments to make the code compile. // Make me compile! Execute `rustlings hint modules2` for hints :) // I AM NOT DONE mod delicious_snacks { - use self::fruits::PEAR as fruit; - use self::veggies::CUCUMBER as veggie; + + // TODO: Fix these use statments + use self::fruits::PEAR as ??? + use self::veggies::CUCUMBER as ??? mod fruits { pub const PEAR: &'static str = "Pear"; diff --git a/exercises/modules/modules3.rs b/exercises/modules/modules3.rs new file mode 100644 index 00000000..8eed77df --- /dev/null +++ b/exercises/modules/modules3.rs @@ -0,0 +1,18 @@ +// modules3.rs +// You can use the 'use' keyword to bring module paths from modules from anywhere +// and especially from the Rust standard library into your scope. +// Bring SystemTime and UNIX_EPOCH +// from the std::time module. Bonus style points if you can do it with one line! +// Make me compile! Execute `rustlings hint modules3` for hints :) + +// I AM NOT DONE + +// TODO: Complete this use statement +use ??? + +fn main() { + match SystemTime::now().duration_since(UNIX_EPOCH) { + Ok(n) => println!("1970-01-01 00:00:00 UTC was {} seconds ago!", n.as_secs()), + Err(_) => panic!("SystemTime before UNIX EPOCH!"), + } +} diff --git a/info.toml b/info.toml index d5008ede..0f68d059 100644 --- a/info.toml +++ b/info.toml @@ -362,11 +362,19 @@ name = "modules2" path = "exercises/modules/modules2.rs" mode = "compile" hint = """ -The delicious_snacks module is trying to present an external -interface (the `fruit` and `veggie` constants) that is different than -its internal structure (the `fruits` and `veggies` modules and -associated constants). It's almost there except for one keyword missing for -each constant.""" +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` statemants to fit the uses in main and +find the one keyword missing for both constants.""" + +[[exercises]] +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.""" # COLLECTIONS From 5423f1be29abc97a5659cac05a819a36d62182f5 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Fri, 3 Sep 2021 08:41:42 +0000 Subject: [PATCH 253/282] docs: update README.md [skip ci] --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c867258c..608bba9b 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -[![All Contributors](https://img.shields.io/badge/all_contributors-102-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-103-orange.svg?style=flat-square)](#contributors-) # rustlings πŸ¦€β€οΈ @@ -304,6 +304,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Rakshit Sinha

πŸ–‹
Damian

πŸ–‹
Ben Armstead

πŸ’» +
anuk909

πŸ–‹ πŸ’» From 44d8047249bc4c32ccc1cbc5de848caea0df8c2f Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Fri, 3 Sep 2021 08:41:43 +0000 Subject: [PATCH 254/282] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 7816a0b8..03e8dd1c 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -947,6 +947,16 @@ "contributions": [ "code" ] + }, + { + "login": "anuk909", + "name": "anuk909", + "avatar_url": "https://avatars.githubusercontent.com/u/34924662?v=4", + "profile": "https://github.com/anuk909", + "contributions": [ + "content", + "code" + ] } ], "contributorsPerLine": 8, From 1c3beb0a59178c950dc05fe8ee2346b017429ae0 Mon Sep 17 00:00:00 2001 From: granddaifuku <49578068+granddaifuku@users.noreply.github.com> Date: Mon, 6 Sep 2021 23:32:39 +0900 Subject: [PATCH 255/282] fix(modules2): fix typo (#835) --- exercises/modules/modules2.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exercises/modules/modules2.rs b/exercises/modules/modules2.rs index 687bb788..87f0c458 100644 --- a/exercises/modules/modules2.rs +++ b/exercises/modules/modules2.rs @@ -1,13 +1,13 @@ // modules2.rs // You can bring module paths into scopes and provide new names for them with the -// 'use' and 'as' keywords. Fix these 'use' statments to make the code compile. +// 'use' and 'as' keywords. Fix these 'use' statements to make the code compile. // Make me compile! Execute `rustlings hint modules2` for hints :) // I AM NOT DONE mod delicious_snacks { - // TODO: Fix these use statments + // TODO: Fix these use statements use self::fruits::PEAR as ??? use self::veggies::CUCUMBER as ??? From 6c41adef63d777a90bf2a80f0abb5efeb872f52b Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Mon, 6 Sep 2021 14:33:03 +0000 Subject: [PATCH 256/282] docs: update README.md [skip ci] --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 608bba9b..e28a4815 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -[![All Contributors](https://img.shields.io/badge/all_contributors-103-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-104-orange.svg?style=flat-square)](#contributors-) # rustlings πŸ¦€β€οΈ @@ -305,6 +305,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Damian

πŸ–‹
Ben Armstead

πŸ’»
anuk909

πŸ–‹ πŸ’» +
granddaifuku

πŸ–‹ From de22b132731bd6f9bae6d0a90707d29e9d3bc389 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Mon, 6 Sep 2021 14:33:05 +0000 Subject: [PATCH 257/282] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 03e8dd1c..5a932d94 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -957,6 +957,15 @@ "content", "code" ] + }, + { + "login": "granddaifuku", + "name": "granddaifuku", + "avatar_url": "https://avatars.githubusercontent.com/u/49578068?v=4", + "profile": "https://granddaifuku.com/", + "contributions": [ + "content" + ] } ], "contributorsPerLine": 8, From 6efa7d5d1554f8973346e9e15dbd5268306a2458 Mon Sep 17 00:00:00 2001 From: "joakim.kartveit" Date: Thu, 9 Sep 2021 15:53:05 +0200 Subject: [PATCH 258/282] Added ignore for .iml files --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 06de8710..253f8f33 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ exercises/clippy/Cargo.toml exercises/clippy/Cargo.lock .idea .vscode +*.iml From a7dc080b95e49146fbaafe6922a6de2f8cb1582a Mon Sep 17 00:00:00 2001 From: ana Date: Tue, 21 Sep 2021 10:36:11 +0200 Subject: [PATCH 259/282] feat: add more watch commands Includes: - quit, to quit the shell instead of having to press Cmd/Ctrl-C or Cmd/Ctrl-D - help, to display an overview of all the commands available in watch mode. Closes #842. --- src/main.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 1e343478..06b41770 100644 --- a/src/main.rs +++ b/src/main.rs @@ -264,7 +264,7 @@ fn main() { fn spawn_watch_shell(failed_exercise_hint: &Arc>>) { let failed_exercise_hint = Arc::clone(failed_exercise_hint); - println!("Type 'hint' or open the corresponding README.md file to get help or type 'clear' to clear the screen."); + println!("Welcome to watch mode! You can type 'help' to get an overview of the commands you can use here."); thread::spawn(move || loop { let mut input = String::new(); match io::stdin().read_line(&mut input) { @@ -276,6 +276,18 @@ fn spawn_watch_shell(failed_exercise_hint: &Arc>>) { } } else if input.eq("clear") { println!("\x1B[2J\x1B[1;1H"); + } else if input.eq("quit") { + println!("Bye!"); + std::process::exit(0); + } else if input.eq("help") { + println!("Commands available to you in watch mode:"); + println!(" hint - prints the current exercise's hint"); + println!(" clear - clears the screen"); + println!(" quit - quits watch mode"); + println!(" help - displays this help message"); + println!(""); + println!("Watch mode automatically re-evaluates the current exercise"); + println!("when you edit a file's contents.") } else { println!("unknown command: {}", input); } From 0a11bad71402b5403143d642f439f57931278c07 Mon Sep 17 00:00:00 2001 From: Weilet <32561597+Weilet@users.noreply.github.com> Date: Tue, 21 Sep 2021 16:43:44 +0800 Subject: [PATCH 260/282] feat(quiz1): add default function name in comment (#838) --- exercises/quiz1.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/quiz1.rs b/exercises/quiz1.rs index 3af1293d..b13b9284 100644 --- a/exercises/quiz1.rs +++ b/exercises/quiz1.rs @@ -10,7 +10,7 @@ // I AM NOT DONE // Put your function here! -// fn ..... { +// fn calculate_apple_price { // Don't modify this function! #[test] From fe726f5bcafd35c56b66c9b17a962b7a5cab5ece Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Tue, 21 Sep 2021 08:44:03 +0000 Subject: [PATCH 261/282] docs: update README.md [skip ci] --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e28a4815..af0cbb8f 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -[![All Contributors](https://img.shields.io/badge/all_contributors-104-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-105-orange.svg?style=flat-square)](#contributors-) # rustlings πŸ¦€β€οΈ @@ -307,6 +307,9 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
anuk909

πŸ–‹ πŸ’»
granddaifuku

πŸ–‹ + +
Weilet

πŸ–‹ + From 9ddd4ca33a4cb2a6b02b03a574682c92de5d7253 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Tue, 21 Sep 2021 08:44:04 +0000 Subject: [PATCH 262/282] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 5a932d94..8811aef5 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -966,6 +966,15 @@ "contributions": [ "content" ] + }, + { + "login": "Weilet", + "name": "Weilet", + "avatar_url": "https://avatars.githubusercontent.com/u/32561597?v=4", + "profile": "https://weilet.me", + "contributions": [ + "content" + ] } ], "contributorsPerLine": 8, From 06d5c0973a3dffa3c6c6f70acb775d4c6630323c Mon Sep 17 00:00:00 2001 From: LIU JIE Date: Tue, 21 Sep 2021 17:50:15 +0800 Subject: [PATCH 263/282] fix(cli): typo in exercise.rs (#848) --- src/exercise.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/exercise.rs b/src/exercise.rs index 53457ace..ec694df9 100644 --- a/src/exercise.rs +++ b/src/exercise.rs @@ -133,7 +133,7 @@ path = "{}.rs""#, "Failed to write πŸ“Ž Clippy πŸ“Ž Cargo.toml file." }; fs::write(CLIPPY_CARGO_TOML_PATH, cargo_toml).expect(cargo_toml_error_msg); - // To support the ability to run the clipy exercises, build + // To support the ability to run the clippy exercises, build // an executable, in addition to running clippy. With a // compilation failure, this would silently fail. But we expect // clippy to reflect the same failure while compiling later. From 9ef63c0b9b892dd572a76db9c95947e77f82eb3c Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Tue, 21 Sep 2021 09:50:31 +0000 Subject: [PATCH 264/282] docs: update README.md [skip ci] --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index af0cbb8f..94ab10f8 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -[![All Contributors](https://img.shields.io/badge/all_contributors-105-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-106-orange.svg?style=flat-square)](#contributors-) # rustlings πŸ¦€β€οΈ @@ -309,6 +309,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Weilet

πŸ–‹ +
LIU JIE

πŸ–‹ From e9c0ca6be2a73c4dc890f2ebeaaec8aeaad06650 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Tue, 21 Sep 2021 09:50:32 +0000 Subject: [PATCH 265/282] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 8811aef5..44d24396 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -975,6 +975,15 @@ "contributions": [ "content" ] + }, + { + "login": "Millione", + "name": "LIU JIE", + "avatar_url": "https://avatars.githubusercontent.com/u/38575932?v=4", + "profile": "https://github.com/Millione", + "contributions": [ + "content" + ] } ], "contributorsPerLine": 8, From 3352b5a4d380df65763b4e64fc9e8938a3adfd80 Mon Sep 17 00:00:00 2001 From: ana Date: Fri, 24 Sep 2021 13:04:30 +0200 Subject: [PATCH 266/282] chore: improve println! usage --- src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 06b41770..d01a8273 100644 --- a/src/main.rs +++ b/src/main.rs @@ -285,7 +285,7 @@ fn spawn_watch_shell(failed_exercise_hint: &Arc>>) { println!(" clear - clears the screen"); println!(" quit - quits watch mode"); println!(" help - displays this help message"); - println!(""); + println!(); println!("Watch mode automatically re-evaluates the current exercise"); println!("when you edit a file's contents.") } else { From 1caef0b43494c8b8cdd6c9260147e70d510f1aca Mon Sep 17 00:00:00 2001 From: Antoine Busch Date: Tue, 14 Sep 2021 20:34:40 +1000 Subject: [PATCH 267/282] feat: Add "quit" command to `rustlings watch` closes: #842 --- src/main.rs | 122 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 72 insertions(+), 50 deletions(-) diff --git a/src/main.rs b/src/main.rs index d01a8273..30096dfe 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,7 +10,8 @@ use std::fs; use std::io::{self, prelude::*}; use std::path::Path; use std::process::{Command, Stdio}; -use std::sync::mpsc::channel; +use std::sync::atomic::{AtomicBool, Ordering}; +use std::sync::mpsc::{RecvTimeoutError, channel}; use std::sync::{Arc, Mutex}; use std::thread; use std::time::Duration; @@ -217,52 +218,60 @@ fn main() { } Subcommands::Watch(_subargs) => { - if let Err(e) = watch(&exercises, verbose) { - println!( - "Error: Could not watch your progress. Error message was {:?}.", - e - ); - println!("Most likely you've run out of disk space or your 'inotify limit' has been reached."); - std::process::exit(1); + match watch(&exercises, verbose) { + Err(e) => { + println!( + "Error: Could not watch your progress. Error message was {:?}.", + e + ); + println!("Most likely you've run out of disk space or your 'inotify limit' has been reached."); + std::process::exit(1); + } + Ok(WatchStatus::Finished) => { + println!( + "{emoji} All exercises completed! {emoji}", + emoji = Emoji("πŸŽ‰", "β˜…") + ); + println!(); + println!("+----------------------------------------------------+"); + println!("| You made it to the Fe-nish line! |"); + println!("+-------------------------- ------------------------+"); + println!(" \\/ "); + println!(" β–’β–’ β–’β–’β–’β–’β–’β–’β–’β–’ β–’β–’β–’β–’β–’β–’β–’β–’ β–’β–’ "); + println!(" β–’β–’β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’β–’β–’ "); + println!(" β–’β–’β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’β–’β–’ "); + println!(" β–‘β–‘β–’β–’β–’β–’β–‘β–‘β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’β–‘β–‘β–’β–’β–’β–’ "); + println!(" β–“β–“β–“β–“β–“β–“β–“β–“ β–“β–“ β–“β–“β–ˆβ–ˆ β–“β–“ β–“β–“β–ˆβ–ˆ β–“β–“ β–“β–“β–“β–“β–“β–“β–“β–“ "); + println!(" β–’β–’β–’β–’ β–’β–’ β–ˆβ–ˆβ–ˆβ–ˆ β–’β–’ β–ˆβ–ˆβ–ˆβ–ˆ β–’β–’β–‘β–‘ β–’β–’β–’β–’ "); + println!(" β–’β–’ β–’β–’β–’β–’β–’β–’ β–’β–’β–’β–’β–’β–’ β–’β–’β–’β–’β–’β–’ β–’β–’ "); + println!(" β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–“β–“β–“β–“β–“β–“β–’β–’β–’β–’β–’β–’β–’β–’β–“β–“β–’β–’β–“β–“β–’β–’β–’β–’β–’β–’β–’β–’ "); + println!(" β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’ "); + println!(" β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–ˆβ–ˆβ–’β–’β–’β–’β–’β–’β–ˆβ–ˆβ–’β–’β–’β–’β–’β–’β–’β–’β–’β–’ "); + println!(" β–’β–’ β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–’β–’β–’β–’β–’β–’β–’β–’β–’β–’ β–’β–’ "); + println!(" β–’β–’ β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’ β–’β–’ "); + println!(" β–’β–’ β–’β–’ β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’ β–’β–’ β–’β–’ "); + println!(" β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’ "); + println!(" β–’β–’ β–’β–’ β–’β–’ β–’β–’ "); + println!(); + println!("We hope you enjoyed learning about the various aspects of Rust!"); + println!( + "If you noticed any issues, please don't hesitate to report them to our repo." + ); + println!("You can also contribute your own exercises to help the greater community!"); + println!(); + println!("Before reporting an issue or contributing, please read our guidelines:"); + println!("https://github.com/rust-lang/rustlings/blob/main/CONTRIBUTING.md"); + } + Ok(WatchStatus::Unfinished) => { + println!("We hope you're enjoying learning about Rust!"); + println!("If you want to continue working on the exercises at a later point, you can simply run `rustlings watch` again"); + } } - println!( - "{emoji} All exercises completed! {emoji}", - emoji = Emoji("πŸŽ‰", "β˜…") - ); - println!(); - println!("+----------------------------------------------------+"); - println!("| You made it to the Fe-nish line! |"); - println!("+-------------------------- ------------------------+"); - println!(" \\/ "); - println!(" β–’β–’ β–’β–’β–’β–’β–’β–’β–’β–’ β–’β–’β–’β–’β–’β–’β–’β–’ β–’β–’ "); - println!(" β–’β–’β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’β–’β–’ "); - println!(" β–’β–’β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’β–’β–’ "); - println!(" β–‘β–‘β–’β–’β–’β–’β–‘β–‘β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’β–‘β–‘β–’β–’β–’β–’ "); - println!(" β–“β–“β–“β–“β–“β–“β–“β–“ β–“β–“ β–“β–“β–ˆβ–ˆ β–“β–“ β–“β–“β–ˆβ–ˆ β–“β–“ β–“β–“β–“β–“β–“β–“β–“β–“ "); - println!(" β–’β–’β–’β–’ β–’β–’ β–ˆβ–ˆβ–ˆβ–ˆ β–’β–’ β–ˆβ–ˆβ–ˆβ–ˆ β–’β–’β–‘β–‘ β–’β–’β–’β–’ "); - println!(" β–’β–’ β–’β–’β–’β–’β–’β–’ β–’β–’β–’β–’β–’β–’ β–’β–’β–’β–’β–’β–’ β–’β–’ "); - println!(" β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–“β–“β–“β–“β–“β–“β–’β–’β–’β–’β–’β–’β–’β–’β–“β–“β–’β–’β–“β–“β–’β–’β–’β–’β–’β–’β–’β–’ "); - println!(" β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’ "); - println!(" β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–ˆβ–ˆβ–’β–’β–’β–’β–’β–’β–ˆβ–ˆβ–’β–’β–’β–’β–’β–’β–’β–’β–’β–’ "); - println!(" β–’β–’ β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–’β–’β–’β–’β–’β–’β–’β–’β–’β–’ β–’β–’ "); - println!(" β–’β–’ β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’ β–’β–’ "); - println!(" β–’β–’ β–’β–’ β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’ β–’β–’ β–’β–’ "); - println!(" β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’ "); - println!(" β–’β–’ β–’β–’ β–’β–’ β–’β–’ "); - println!(); - println!("We hope you enjoyed learning about the various aspects of Rust!"); - println!( - "If you noticed any issues, please don't hesitate to report them to our repo." - ); - println!("You can also contribute your own exercises to help the greater community!"); - println!(); - println!("Before reporting an issue or contributing, please read our guidelines:"); - println!("https://github.com/rust-lang/rustlings/blob/main/CONTRIBUTING.md"); } } } -fn spawn_watch_shell(failed_exercise_hint: &Arc>>) { +fn spawn_watch_shell(failed_exercise_hint: &Arc>>, should_quit: Arc) { let failed_exercise_hint = Arc::clone(failed_exercise_hint); println!("Welcome to watch mode! You can type 'help' to get an overview of the commands you can use here."); thread::spawn(move || loop { @@ -270,15 +279,15 @@ fn spawn_watch_shell(failed_exercise_hint: &Arc>>) { match io::stdin().read_line(&mut input) { Ok(_) => { let input = input.trim(); - if input.eq("hint") { + if input == "hint" { if let Some(hint) = &*failed_exercise_hint.lock().unwrap() { println!("{}", hint); } - } else if input.eq("clear") { + } else if input == "clear" { println!("\x1B[2J\x1B[1;1H"); } else if input.eq("quit") { + should_quit.store(true, Ordering::SeqCst); println!("Bye!"); - std::process::exit(0); } else if input.eq("help") { println!("Commands available to you in watch mode:"); println!(" hint - prints the current exercise's hint"); @@ -318,7 +327,12 @@ fn find_exercise<'a>(name: &str, exercises: &'a [Exercise]) -> &'a Exercise { } } -fn watch(exercises: &[Exercise], verbose: bool) -> notify::Result<()> { +enum WatchStatus { + Finished, + Unfinished, +} + +fn watch(exercises: &[Exercise], verbose: bool) -> notify::Result { /* Clears the terminal with an ANSI escape code. Works in UNIX and newer Windows terminals. */ fn clear_screen() { @@ -326,6 +340,7 @@ fn watch(exercises: &[Exercise], verbose: bool) -> notify::Result<()> { } let (tx, rx) = channel(); + let should_quit = Arc::new(AtomicBool::new(false)); let mut watcher: RecommendedWatcher = Watcher::new(tx, Duration::from_secs(2))?; watcher.watch(Path::new("./exercises"), RecursiveMode::Recursive)?; @@ -334,12 +349,12 @@ fn watch(exercises: &[Exercise], verbose: bool) -> notify::Result<()> { let to_owned_hint = |t: &Exercise| t.hint.to_owned(); let failed_exercise_hint = match verify(exercises.iter(), verbose) { - Ok(_) => return Ok(()), + Ok(_) => return Ok(WatchStatus::Finished), Err(exercise) => Arc::new(Mutex::new(Some(to_owned_hint(exercise)))), }; - spawn_watch_shell(&failed_exercise_hint); + spawn_watch_shell(&failed_exercise_hint, Arc::clone(&should_quit)); loop { - match rx.recv() { + match rx.recv_timeout(Duration::from_secs(1)) { Ok(event) => match event { DebouncedEvent::Create(b) | DebouncedEvent::Chmod(b) | DebouncedEvent::Write(b) => { if b.extension() == Some(OsStr::new("rs")) && b.exists() { @@ -355,7 +370,7 @@ fn watch(exercises: &[Exercise], verbose: bool) -> notify::Result<()> { ); clear_screen(); match verify(pending_exercises, verbose) { - Ok(_) => return Ok(()), + Ok(_) => return Ok(WatchStatus::Finished), Err(exercise) => { let mut failed_exercise_hint = failed_exercise_hint.lock().unwrap(); *failed_exercise_hint = Some(to_owned_hint(exercise)); @@ -365,8 +380,15 @@ fn watch(exercises: &[Exercise], verbose: bool) -> notify::Result<()> { } _ => {} }, + Err(RecvTimeoutError::Timeout) => { + // the timeout expired, just check the `should_quit` variable below then loop again + } Err(e) => println!("watch error: {:?}", e), } + // Check if we need to exit + if should_quit.load(Ordering::SeqCst) { + return Ok(WatchStatus::Unfinished); + } } } From c4b59aa593fc4ae952f69133068cb8f8f5ac0866 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Sat, 25 Sep 2021 08:47:55 +0000 Subject: [PATCH 268/282] docs: update README.md [skip ci] --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 94ab10f8..8435a107 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -[![All Contributors](https://img.shields.io/badge/all_contributors-106-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-107-orange.svg?style=flat-square)](#contributors-) # rustlings πŸ¦€β€οΈ @@ -310,6 +310,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Weilet

πŸ–‹
LIU JIE

πŸ–‹ +
Antoine BΓΌsch

πŸ’» From a1b9c50f36513ce8f8ba26dfdaec2bb427fffeb6 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Sat, 25 Sep 2021 08:47:56 +0000 Subject: [PATCH 269/282] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 44d24396..345a7ec9 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -984,6 +984,15 @@ "contributions": [ "content" ] + }, + { + "login": "abusch", + "name": "Antoine BΓΌsch", + "avatar_url": "https://avatars.githubusercontent.com/u/506344?v=4", + "profile": "https://github.com/abusch", + "contributions": [ + "code" + ] } ], "contributorsPerLine": 8, From d75759e829fdcd64ef071cf4b6eae2a011a7718b Mon Sep 17 00:00:00 2001 From: frogtd <31412003+frogtd@users.noreply.github.com> Date: Sat, 25 Sep 2021 04:52:18 -0400 Subject: [PATCH 270/282] fix(move_semantics5): change &mut *y to &mut x (#814) Instead of having to explain why ```rs let mut x = 100; let y = &mut x; let mut z_owned = *y; let z = &mut z_owned; *y += 100; *z += 1000; ``` and ```rs let mut x = 100; let y = &mut x; let z = &mut *y; *y += 100; *z += 1000; ``` are different, you still get the point across about having only one mutable reference. As it stands, this exercise does too much (dereferencing and having only one mutable reference), and by doing so confuses people. Example of someone being confused by this: --- exercises/move_semantics/move_semantics5.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/move_semantics/move_semantics5.rs b/exercises/move_semantics/move_semantics5.rs index 5449e951..1afe16c5 100644 --- a/exercises/move_semantics/move_semantics5.rs +++ b/exercises/move_semantics/move_semantics5.rs @@ -8,7 +8,7 @@ fn main() { let mut x = 100; let y = &mut x; - let z = &mut *y; + let z = &mut x; *y += 100; *z += 1000; assert_eq!(x, 1200); From e106d7a4f4d375fd8648cde25e4e7a1c4c6bdeac Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Sat, 25 Sep 2021 08:53:04 +0000 Subject: [PATCH 271/282] docs: update README.md [skip ci] --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8435a107..ac1d84d3 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -[![All Contributors](https://img.shields.io/badge/all_contributors-107-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-108-orange.svg?style=flat-square)](#contributors-) # rustlings πŸ¦€β€οΈ @@ -311,6 +311,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Weilet

πŸ–‹
LIU JIE

πŸ–‹
Antoine BΓΌsch

πŸ’» +
frogtd

πŸ–‹ From ab5ecbee7a8fab44867cd18ab030dc9de7185360 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Sat, 25 Sep 2021 08:53:05 +0000 Subject: [PATCH 272/282] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 345a7ec9..d18743c2 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -993,6 +993,15 @@ "contributions": [ "code" ] + }, + { + "login": "frogtd", + "name": "frogtd", + "avatar_url": "https://avatars.githubusercontent.com/u/31412003?v=4", + "profile": "https://frogtd.com/", + "contributions": [ + "content" + ] } ], "contributorsPerLine": 8, From 882d535ba8628d5e0b37e8664b3e2f26260b2671 Mon Sep 17 00:00:00 2001 From: Taylor Yu Date: Wed, 9 Jun 2021 23:26:10 -0500 Subject: [PATCH 273/282] feat: add advanced_errs1 New section and exercise to demonstrate the `From` trait for errors and its usefulness with the `?` operator. --- exercises/advanced_errors/advanced_errs1.rs | 98 +++++++++++++++++++++ info.toml | 20 +++++ 2 files changed, 118 insertions(+) create mode 100644 exercises/advanced_errors/advanced_errs1.rs diff --git a/exercises/advanced_errors/advanced_errs1.rs b/exercises/advanced_errors/advanced_errs1.rs new file mode 100644 index 00000000..4bc7b635 --- /dev/null +++ b/exercises/advanced_errors/advanced_errs1.rs @@ -0,0 +1,98 @@ +// advanced_errs1.rs + +// Remember back in errors6, we had multiple mapping functions so that we +// could translate lower-level errors into our custom error type using +// `map_err()`? What if we could use the `?` operator directly instead? + +// Make this code compile! Execute `rustlings hint advanced_errs1` for +// hints :) + +// I AM NOT DONE + +use std::num::ParseIntError; +use std::str::FromStr; + +// This is a custom error type that we will be using in the `FromStr` +// implementation. +#[derive(PartialEq, Debug)] +enum ParsePosNonzeroError { + Creation(CreationError), + ParseInt(ParseIntError), +} + +impl From for ParsePosNonzeroError { + fn from(e: CreationError) -> Self { + // TODO: complete this implementation so that the `?` operator will + // work for `CreationError` + } +} + +// TODO: implement another instance of the `From` trait here so that the +// `?` operator will work in the other place in the `FromStr` +// implementation below. + +// Don't change anything below this line. + +impl FromStr for PositiveNonzeroInteger { + type Err = ParsePosNonzeroError; + fn from_str(s: &str) -> Result { + let x: i64 = s.parse()?; + Ok(PositiveNonzeroInteger::new(x)?) + } +} + +#[derive(PartialEq, Debug)] +struct PositiveNonzeroInteger(u64); + +#[derive(PartialEq, Debug)] +enum CreationError { + Negative, + Zero, +} + +impl PositiveNonzeroInteger { + fn new(value: i64) -> Result { + match value { + x if x < 0 => Err(CreationError::Negative), + x if x == 0 => Err(CreationError::Zero), + x => Ok(PositiveNonzeroInteger(x as u64)), + } + } +} + +#[cfg(test)] +mod test { + use super::*; + + #[test] + fn test_parse_error() { + // We can't construct a ParseIntError, so we have to pattern match. + assert!(matches!( + PositiveNonzeroInteger::from_str("not a number"), + Err(ParsePosNonzeroError::ParseInt(_)) + )); + } + + #[test] + fn test_negative() { + assert_eq!( + PositiveNonzeroInteger::from_str("-555"), + Err(ParsePosNonzeroError::Creation(CreationError::Negative)) + ); + } + + #[test] + fn test_zero() { + assert_eq!( + PositiveNonzeroInteger::from_str("0"), + Err(ParsePosNonzeroError::Creation(CreationError::Zero)) + ); + } + + #[test] + fn test_positive() { + let x = PositiveNonzeroInteger::new(42); + assert!(x.is_ok()); + assert_eq!(PositiveNonzeroInteger::from_str("42"), Ok(x.unwrap())); + } +} diff --git a/info.toml b/info.toml index f5af8840..8e24b7db 100644 --- a/info.toml +++ b/info.toml @@ -974,3 +974,23 @@ path = "exercises/conversions/as_ref_mut.rs" mode = "test" hint = """ Add AsRef as a trait bound to the functions.""" + +# ADVANCED ERRORS + +[[exercises]] +name = "advanced_errs1" +path = "exercises/advanced_errors/advanced_errs1.rs" +mode = "test" +hint = """ +This exercise uses an updated version of the code in errors6. The parsing +code is now in an implementation of the `FromStr` trait. Note that the +parsing code uses `?` directly, without any calls to `map_err()`. There is +one partial implementation of the `From` trait example that you should +complete. + +Details: The `?` operator calls `From::from()` on the error type to convert +it to the error type of the return type of the surrounding function. + +Hint: You will need to write another implementation of `From` that has a +different input type. +""" From abd6b70c72dc6426752ff41f09160b839e5c449e Mon Sep 17 00:00:00 2001 From: Taylor Yu Date: Fri, 25 Jun 2021 16:52:10 -0500 Subject: [PATCH 274/282] feat: add advanced_errs2 New exercise to demonstrate traits that make it easier for other code to consume our custom error types. --- exercises/advanced_errors/advanced_errs2.rs | 203 ++++++++++++++++++++ info.toml | 32 +++ 2 files changed, 235 insertions(+) create mode 100644 exercises/advanced_errors/advanced_errs2.rs diff --git a/exercises/advanced_errors/advanced_errs2.rs b/exercises/advanced_errors/advanced_errs2.rs new file mode 100644 index 00000000..d9d44d06 --- /dev/null +++ b/exercises/advanced_errors/advanced_errs2.rs @@ -0,0 +1,203 @@ +// advanced_errs2.rs + +// This exercise demonstrates a few traits that are useful for custom error +// types to implement, especially so that other code can consume the custom +// error type more usefully. + +// Make this compile, and make the tests pass! +// Execute `rustlings hint advanced_errs2` for hints. + +// Steps: +// 1. Implement a missing trait so that `main()` will compile. +// 2. Complete the partial implementation of `From` for +// `ParseClimateError`. +// 3. Handle the missing error cases in the `FromStr` implementation for +// `Climate`. +// 4. Complete the partial implementation of `Display` for +// `ParseClimateError`. + +// I AM NOT DONE + +use std::error::Error; +use std::fmt::{self, Display, Formatter}; +use std::num::{ParseFloatError, ParseIntError}; +use std::str::FromStr; + +// This is the custom error type that we will be using for the parser for +// `Climate`. +#[derive(Debug, PartialEq)] +enum ParseClimateError { + Empty, + BadLen, + NoCity, + ParseInt(ParseIntError), + ParseFloat(ParseFloatError), +} + +// This `From` implementation allows the `?` operator to work on +// `ParseIntError` values. +impl From for ParseClimateError { + fn from(e: ParseIntError) -> Self { + Self::ParseInt(e) + } +} + +// This `From` implementation allows the `?` operator to work on +// `ParseFloatError` values. +impl From for ParseClimateError { + fn from(e: ParseFloatError) -> Self { + // TODO: Complete this function + } +} + +// TODO: Implement a missing trait so that `main()` below will compile. It +// is not necessary to implement any methods inside the missing trait. + +// The `Display` trait allows for other code to obtain the error formatted +// as a user-visible string. +impl Display for ParseClimateError { + // TODO: Complete this function so that it produces the correct strings + // for each error variant. + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { + // Imports the variants to make the following code more compact. + use ParseClimateError::*; + match self { + NoCity => write!(f, "no city name"), + ParseFloat(e) => write!(f, "error parsing temperature: {}", e), + _ => write!(f, "unhandled error!"), + } + } +} + +#[derive(Debug, PartialEq)] +struct Climate { + city: String, + year: u32, + temp: f32, +} + +// Parser for `Climate`. +// 1. Split the input string into 3 fields: city, year, temp. +// 2. Return an error if the string is empty or has the wrong number of +// fields. +// 3. Return an error if the city name is empty. +// 4. Parse the year as a `u32` and return an error if that fails. +// 5. Parse the temp as a `f32` and return an error if that fails. +// 6. Return an `Ok` value containing the completed `Climate` value. +impl FromStr for Climate { + type Err = ParseClimateError; + // TODO: Complete this function by making it handle the missing error + // cases. + fn from_str(s: &str) -> Result { + let v: Vec<_> = s.split(',').collect(); + let (city, year, temp) = match &v[..] { + [city, year, temp] => (city.to_string(), year, temp), + _ => return Err(ParseClimateError::BadLen), + }; + let year: u32 = year.parse()?; + let temp: f32 = temp.parse()?; + Ok(Climate { city, year, temp }) + } +} + +// Don't change anything below this line (other than to enable ignored +// tests). + +fn main() -> Result<(), Box> { + println!("{:?}", "Hong Kong,1999,25.7".parse::()?); + println!("{:?}", "".parse::()?); + Ok(()) +} + +#[cfg(test)] +mod test { + use super::*; + #[test] + fn test_empty() { + let res = "".parse::(); + assert_eq!(res, Err(ParseClimateError::Empty)); + assert_eq!(res.unwrap_err().to_string(), "empty input"); + } + #[test] + fn test_short() { + let res = "Boston,1991".parse::(); + assert_eq!(res, Err(ParseClimateError::BadLen)); + assert_eq!(res.unwrap_err().to_string(), "incorrect number of fields"); + } + #[test] + fn test_long() { + let res = "Paris,1920,17.2,extra".parse::(); + assert_eq!(res, Err(ParseClimateError::BadLen)); + assert_eq!(res.unwrap_err().to_string(), "incorrect number of fields"); + } + #[test] + fn test_no_city() { + let res = ",1997,20.5".parse::(); + assert_eq!(res, Err(ParseClimateError::NoCity)); + assert_eq!(res.unwrap_err().to_string(), "no city name"); + } + #[test] + fn test_parse_int_neg() { + let res = "Barcelona,-25,22.3".parse::(); + assert!(matches!(res, Err(ParseClimateError::ParseInt(_)))); + let err = res.unwrap_err(); + if let ParseClimateError::ParseInt(ref inner) = err { + assert_eq!( + err.to_string(), + format!("error parsing year: {}", inner.to_string()) + ); + } else { + unreachable!(); + }; + } + #[test] + fn test_parse_int_bad() { + let res = "Beijing,foo,15.0".parse::(); + assert!(matches!(res, Err(ParseClimateError::ParseInt(_)))); + let err = res.unwrap_err(); + if let ParseClimateError::ParseInt(ref inner) = err { + assert_eq!( + err.to_string(), + format!("error parsing year: {}", inner.to_string()) + ); + } else { + unreachable!(); + }; + } + #[test] + fn test_parse_float() { + let res = "Manila,2001,bar".parse::(); + assert!(matches!(res, Err(ParseClimateError::ParseFloat(_)))); + let err = res.unwrap_err(); + if let ParseClimateError::ParseFloat(ref inner) = err { + assert_eq!( + err.to_string(), + format!("error parsing temperature: {}", inner.to_string()) + ); + } else { + unreachable!(); + }; + } + #[test] + fn test_parse_good() { + let res = "Munich,2015,23.1".parse::(); + assert_eq!( + res, + Ok(Climate { + city: "Munich".to_string(), + year: 2015, + temp: 23.1, + }) + ); + } + #[test] + #[ignore] + fn test_downcast() { + let res = "SΓ£o Paulo,-21,28.5".parse::(); + assert!(matches!(res, Err(ParseClimateError::ParseInt(_)))); + let err = res.unwrap_err(); + let inner: Option<&(dyn Error + 'static)> = err.source(); + assert!(inner.is_some()); + assert!(inner.unwrap().is::()); + } +} diff --git a/info.toml b/info.toml index 8e24b7db..1b8c65d2 100644 --- a/info.toml +++ b/info.toml @@ -994,3 +994,35 @@ it to the error type of the return type of the surrounding function. Hint: You will need to write another implementation of `From` that has a different input type. """ + +[[exercises]] +name = "advanced_errs2" +path = "exercises/advanced_errors/advanced_errs2.rs" +mode = "test" +hint = """ +This exercise demonstrates a few traits that are useful for custom error +types to implement. These traits make it easier for other code to consume +the custom error type. + +Follow the steps in the comment near the top of the file. You will have to +supply a missing trait implementation, and complete a few incomplete ones. + +You may find these pages to be helpful references: +https://doc.rust-lang.org/stable/rust-by-example/error/multiple_error_types/define_error_type.html +https://doc.rust-lang.org/stable/rust-by-example/error/multiple_error_types/boxing_errors.html +https://doc.rust-lang.org/stable/rust-by-example/error/multiple_error_types/wrap_error.html + +Hint: What trait must our error type have for `main()` to return the return +type that it returns? + +Another hint: It's not necessary to implement any methods inside the missing +trait. (Some methods have default implementations that are supplied by the +trait.) + +Another hint: Consult the tests to determine which error variants (and which +error message text) to produce for certain error conditions. + +Challenge: There is one test that is marked `#[ignore]`. Can you supply the +missing code that will make it pass? You may want to consult the standard +library documentation for a certain trait for more hints. +""" From d57c1830280b2dbc1b9fe2ac3f48b51add591412 Mon Sep 17 00:00:00 2001 From: ana Date: Sat, 25 Sep 2021 11:23:05 +0200 Subject: [PATCH 275/282] release: 4.6.0 --- CHANGELOG.md | 26 ++++++++++++ Cargo.lock | 2 +- Cargo.toml | 2 +- README.md | 4 +- src/main.rs | 109 ++++++++++++++++++++++++++------------------------- 5 files changed, 86 insertions(+), 57 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 67b8cdc3..fcc39e42 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,29 @@ + +## 4.6.0 (2021-09-25) + + +#### Features + +* add advanced_errs2 ([abd6b70c](https://github.com/rust-lang/rustlings/commit/abd6b70c72dc6426752ff41f09160b839e5c449e)) +* add advanced_errs1 ([882d535b](https://github.com/rust-lang/rustlings/commit/882d535ba8628d5e0b37e8664b3e2f26260b2671)) +* Add a farewell message when quitting `watch` ([1caef0b4](https://github.com/rust-lang/rustlings/commit/1caef0b43494c8b8cdd6c9260147e70d510f1aca)) +* add more watch commands ([a7dc080b](https://github.com/rust-lang/rustlings/commit/a7dc080b95e49146fbaafe6922a6de2f8cb1582a), closes [#842](https://github.com/rust-lang/rustlings/issues/842)) +* **modules:** update exercises, add modules3 (#822) ([dfd2fab4](https://github.com/rust-lang/rustlings/commit/dfd2fab4f33d1bf59e2e5ee03123c0c9a67a9481)) +* **quiz1:** add default function name in comment (#838) ([0a11bad7](https://github.com/rust-lang/rustlings/commit/0a11bad71402b5403143d642f439f57931278c07)) + +#### Bug Fixes + +* Correct small typo in exercises/conversions/from_str.rs ([86cc8529](https://github.com/rust-lang/rustlings/commit/86cc85295ae36948963ae52882e285d7e3e29323)) +* **cli:** typo in exercise.rs (#848) ([06d5c097](https://github.com/rust-lang/rustlings/commit/06d5c0973a3dffa3c6c6f70acb775d4c6630323c)) +* **from_str, try_from_into:** custom error types ([2dc93cad](https://github.com/rust-lang/rustlings/commit/2dc93caddad43821743e4903d89b355df58d7a49)) +* **modules2:** fix typo (#835) ([1c3beb0a](https://github.com/rust-lang/rustlings/commit/1c3beb0a59178c950dc05fe8ee2346b017429ae0)) +* **move_semantics5:** + * change &mut *y to &mut x (#814) ([d75759e8](https://github.com/rust-lang/rustlings/commit/d75759e829fdcd64ef071cf4b6eae2a011a7718b)) + * Clarify instructions ([df25684c](https://github.com/rust-lang/rustlings/commit/df25684cb79f8413915e00b5efef29369849cef1)) +* **quiz1:** Fix inconsistent wording (#826) ([03131a3d](https://github.com/rust-lang/rustlings/commit/03131a3d35d9842598150f9da817f7cc26e2669a)) + + + ## 4.5.0 (2021-07-07) diff --git a/Cargo.lock b/Cargo.lock index 57b211be..e536d1b7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -541,7 +541,7 @@ checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" [[package]] name = "rustlings" -version = "4.5.0" +version = "4.6.0" dependencies = [ "argh", "assert_cmd", diff --git a/Cargo.toml b/Cargo.toml index 615a09c3..3b2a85a7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rustlings" -version = "4.5.0" +version = "4.6.0" authors = ["anastasie ", "Carol (Nichols || Goulding) "] edition = "2018" diff --git a/README.md b/README.md index ac1d84d3..18e0b73a 100644 --- a/README.md +++ b/README.md @@ -60,8 +60,8 @@ When you get a permission denied message then you have to exclude the directory Basically: Clone the repository at the latest tag, run `cargo install`. ```bash -# find out the latest version at https://github.com/rust-lang/rustlings/releases/latest (on edit 4.5.0) -git clone -b 4.5.0 --depth 1 https://github.com/rust-lang/rustlings +# find out the latest version at https://github.com/rust-lang/rustlings/releases/latest (on edit 4.6.0) +git clone -b 4.6.0 --depth 1 https://github.com/rust-lang/rustlings cd rustlings cargo install --force --path . ``` diff --git a/src/main.rs b/src/main.rs index 30096dfe..32e7bba2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -11,7 +11,7 @@ use std::io::{self, prelude::*}; use std::path::Path; use std::process::{Command, Stdio}; use std::sync::atomic::{AtomicBool, Ordering}; -use std::sync::mpsc::{RecvTimeoutError, channel}; +use std::sync::mpsc::{channel, RecvTimeoutError}; use std::sync::{Arc, Mutex}; use std::thread; use std::time::Duration; @@ -24,7 +24,7 @@ mod run; mod verify; // In sync with crate version -const VERSION: &str = "4.5.0"; +const VERSION: &str = "4.6.0"; #[derive(FromArgs, PartialEq, Debug)] /// Rustlings is a collection of small exercises to get you used to writing and reading Rust code @@ -217,61 +217,64 @@ fn main() { verify(&exercises, verbose).unwrap_or_else(|_| std::process::exit(1)); } - Subcommands::Watch(_subargs) => { - match watch(&exercises, verbose) { - Err(e) => { - println!( - "Error: Could not watch your progress. Error message was {:?}.", - e - ); - println!("Most likely you've run out of disk space or your 'inotify limit' has been reached."); - std::process::exit(1); - } - Ok(WatchStatus::Finished) => { - println!( - "{emoji} All exercises completed! {emoji}", - emoji = Emoji("πŸŽ‰", "β˜…") - ); - println!(); - println!("+----------------------------------------------------+"); - println!("| You made it to the Fe-nish line! |"); - println!("+-------------------------- ------------------------+"); - println!(" \\/ "); - println!(" β–’β–’ β–’β–’β–’β–’β–’β–’β–’β–’ β–’β–’β–’β–’β–’β–’β–’β–’ β–’β–’ "); - println!(" β–’β–’β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’β–’β–’ "); - println!(" β–’β–’β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’β–’β–’ "); - println!(" β–‘β–‘β–’β–’β–’β–’β–‘β–‘β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’β–‘β–‘β–’β–’β–’β–’ "); - println!(" β–“β–“β–“β–“β–“β–“β–“β–“ β–“β–“ β–“β–“β–ˆβ–ˆ β–“β–“ β–“β–“β–ˆβ–ˆ β–“β–“ β–“β–“β–“β–“β–“β–“β–“β–“ "); - println!(" β–’β–’β–’β–’ β–’β–’ β–ˆβ–ˆβ–ˆβ–ˆ β–’β–’ β–ˆβ–ˆβ–ˆβ–ˆ β–’β–’β–‘β–‘ β–’β–’β–’β–’ "); - println!(" β–’β–’ β–’β–’β–’β–’β–’β–’ β–’β–’β–’β–’β–’β–’ β–’β–’β–’β–’β–’β–’ β–’β–’ "); - println!(" β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–“β–“β–“β–“β–“β–“β–’β–’β–’β–’β–’β–’β–’β–’β–“β–“β–’β–’β–“β–“β–’β–’β–’β–’β–’β–’β–’β–’ "); - println!(" β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’ "); - println!(" β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–ˆβ–ˆβ–’β–’β–’β–’β–’β–’β–ˆβ–ˆβ–’β–’β–’β–’β–’β–’β–’β–’β–’β–’ "); - println!(" β–’β–’ β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–’β–’β–’β–’β–’β–’β–’β–’β–’β–’ β–’β–’ "); - println!(" β–’β–’ β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’ β–’β–’ "); - println!(" β–’β–’ β–’β–’ β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’ β–’β–’ β–’β–’ "); - println!(" β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’ "); - println!(" β–’β–’ β–’β–’ β–’β–’ β–’β–’ "); - println!(); - println!("We hope you enjoyed learning about the various aspects of Rust!"); - println!( - "If you noticed any issues, please don't hesitate to report them to our repo." - ); - println!("You can also contribute your own exercises to help the greater community!"); - println!(); - println!("Before reporting an issue or contributing, please read our guidelines:"); - println!("https://github.com/rust-lang/rustlings/blob/main/CONTRIBUTING.md"); - } - Ok(WatchStatus::Unfinished) => { - println!("We hope you're enjoying learning about Rust!"); - println!("If you want to continue working on the exercises at a later point, you can simply run `rustlings watch` again"); - } + Subcommands::Watch(_subargs) => match watch(&exercises, verbose) { + Err(e) => { + println!( + "Error: Could not watch your progress. Error message was {:?}.", + e + ); + println!("Most likely you've run out of disk space or your 'inotify limit' has been reached."); + std::process::exit(1); } - } + Ok(WatchStatus::Finished) => { + println!( + "{emoji} All exercises completed! {emoji}", + emoji = Emoji("πŸŽ‰", "β˜…") + ); + println!(); + println!("+----------------------------------------------------+"); + println!("| You made it to the Fe-nish line! |"); + println!("+-------------------------- ------------------------+"); + println!(" \\/ "); + println!(" β–’β–’ β–’β–’β–’β–’β–’β–’β–’β–’ β–’β–’β–’β–’β–’β–’β–’β–’ β–’β–’ "); + println!(" β–’β–’β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’β–’β–’ "); + println!(" β–’β–’β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’β–’β–’ "); + println!(" β–‘β–‘β–’β–’β–’β–’β–‘β–‘β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’β–‘β–‘β–’β–’β–’β–’ "); + println!(" β–“β–“β–“β–“β–“β–“β–“β–“ β–“β–“ β–“β–“β–ˆβ–ˆ β–“β–“ β–“β–“β–ˆβ–ˆ β–“β–“ β–“β–“β–“β–“β–“β–“β–“β–“ "); + println!(" β–’β–’β–’β–’ β–’β–’ β–ˆβ–ˆβ–ˆβ–ˆ β–’β–’ β–ˆβ–ˆβ–ˆβ–ˆ β–’β–’β–‘β–‘ β–’β–’β–’β–’ "); + println!(" β–’β–’ β–’β–’β–’β–’β–’β–’ β–’β–’β–’β–’β–’β–’ β–’β–’β–’β–’β–’β–’ β–’β–’ "); + println!(" β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–“β–“β–“β–“β–“β–“β–’β–’β–’β–’β–’β–’β–’β–’β–“β–“β–’β–’β–“β–“β–’β–’β–’β–’β–’β–’β–’β–’ "); + println!(" β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’ "); + println!(" β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–ˆβ–ˆβ–’β–’β–’β–’β–’β–’β–ˆβ–ˆβ–’β–’β–’β–’β–’β–’β–’β–’β–’β–’ "); + println!(" β–’β–’ β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–’β–’β–’β–’β–’β–’β–’β–’β–’β–’ β–’β–’ "); + println!(" β–’β–’ β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’ β–’β–’ "); + println!(" β–’β–’ β–’β–’ β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’ β–’β–’ β–’β–’ "); + println!(" β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’ β–’β–’ "); + println!(" β–’β–’ β–’β–’ β–’β–’ β–’β–’ "); + println!(); + println!("We hope you enjoyed learning about the various aspects of Rust!"); + println!( + "If you noticed any issues, please don't hesitate to report them to our repo." + ); + println!( + "You can also contribute your own exercises to help the greater community!" + ); + println!(); + println!("Before reporting an issue or contributing, please read our guidelines:"); + println!("https://github.com/rust-lang/rustlings/blob/main/CONTRIBUTING.md"); + } + Ok(WatchStatus::Unfinished) => { + println!("We hope you're enjoying learning about Rust!"); + println!("If you want to continue working on the exercises at a later point, you can simply run `rustlings watch` again"); + } + }, } } -fn spawn_watch_shell(failed_exercise_hint: &Arc>>, should_quit: Arc) { +fn spawn_watch_shell( + failed_exercise_hint: &Arc>>, + should_quit: Arc, +) { let failed_exercise_hint = Arc::clone(failed_exercise_hint); println!("Welcome to watch mode! You can type 'help' to get an overview of the commands you can use here."); thread::spawn(move || loop { From bf33829da240375d086f96267fc2e02fa6b07001 Mon Sep 17 00:00:00 2001 From: Zhenghao Lu <54395432+EmisonLu@users.noreply.github.com> Date: Mon, 27 Sep 2021 16:03:28 +0800 Subject: [PATCH 276/282] fix(structs3): remove redundant 'return' (#852) --- exercises/structs/structs3.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exercises/structs/structs3.rs b/exercises/structs/structs3.rs index a80d0625..b3aa2825 100644 --- a/exercises/structs/structs3.rs +++ b/exercises/structs/structs3.rs @@ -18,11 +18,11 @@ impl Package { if weight_in_grams <= 0 { // Something goes here... } else { - return Package { + Package { sender_country, recipient_country, weight_in_grams, - }; + } } } From fed4fe78bbc0f4a9dbace1a556811a9f506237b6 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Mon, 27 Sep 2021 08:03:46 +0000 Subject: [PATCH 277/282] docs: update README.md [skip ci] --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 18e0b73a..1c3709cc 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -[![All Contributors](https://img.shields.io/badge/all_contributors-108-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-109-orange.svg?style=flat-square)](#contributors-) # rustlings πŸ¦€β€οΈ @@ -312,6 +312,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
LIU JIE

πŸ–‹
Antoine BΓΌsch

πŸ’»
frogtd

πŸ–‹ +
Zhenghao Lu

πŸ–‹ From e3cfaa246dbef9ebea5ca020bdbaf018194b4974 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Mon, 27 Sep 2021 08:03:47 +0000 Subject: [PATCH 278/282] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index d18743c2..21089c52 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -1002,6 +1002,15 @@ "contributions": [ "content" ] + }, + { + "login": "EmisonLu", + "name": "Zhenghao Lu", + "avatar_url": "https://avatars.githubusercontent.com/u/54395432?v=4", + "profile": "https://github.com/EmisonLu", + "contributions": [ + "content" + ] } ], "contributorsPerLine": 8, From 46c28d5cef3d8446b5a356b19d8dbc725f91a3a0 Mon Sep 17 00:00:00 2001 From: Fredrik Enestad Date: Thu, 30 Sep 2021 10:18:36 +0200 Subject: [PATCH 279/282] fix(move_semantics5): correct typo (#857) --- exercises/move_semantics/move_semantics5.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/move_semantics/move_semantics5.rs b/exercises/move_semantics/move_semantics5.rs index 1afe16c5..c4704f9e 100644 --- a/exercises/move_semantics/move_semantics5.rs +++ b/exercises/move_semantics/move_semantics5.rs @@ -1,5 +1,5 @@ // move_semantics5.rs -// Make me compile only be reordering the lines in `main()`, but without +// Make me compile only by reordering the lines in `main()`, but without // adding, changing or removing any of them. // Execute `rustlings hint move_semantics5` for hints :) From 574bbffe0b11b5426970e4710a2275776690e85e Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Thu, 30 Sep 2021 08:18:52 +0000 Subject: [PATCH 280/282] docs: update README.md [skip ci] --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1c3709cc..6e5ce3f6 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -[![All Contributors](https://img.shields.io/badge/all_contributors-109-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-110-orange.svg?style=flat-square)](#contributors-) # rustlings πŸ¦€β€οΈ @@ -313,6 +313,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Antoine BΓΌsch

πŸ’»
frogtd

πŸ–‹
Zhenghao Lu

πŸ–‹ +
Fredrik Enestad

πŸ–‹ From ae54c17b6a5ca63705192011d11d371bb51eee97 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Thu, 30 Sep 2021 08:18:53 +0000 Subject: [PATCH 281/282] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 21089c52..fe18385f 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -1011,6 +1011,15 @@ "contributions": [ "content" ] + }, + { + "login": "fredr", + "name": "Fredrik Enestad", + "avatar_url": "https://avatars.githubusercontent.com/u/762956?v=4", + "profile": "https://soundtrackyourbrand.com", + "contributions": [ + "content" + ] } ], "contributorsPerLine": 8, From 1c0fe3cbcca85f90b3985985b8e265ee872a2ab2 Mon Sep 17 00:00:00 2001 From: rlch Date: Sat, 2 Oct 2021 23:59:23 +1000 Subject: [PATCH 282/282] fix: few spelling mistakes --- info.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/info.toml b/info.toml index 21406630..5eece6d7 100644 --- a/info.toml +++ b/info.toml @@ -364,7 +364,7 @@ mode = "compile" hint = """ 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` statemants to fit the uses in main and +associated constants). Complete the `use` statements to fit the uses in main and find the one keyword missing for both constants.""" [[exercises]]