From 3080141c5ffc6c113506a44e00b7b949a8cc7648 Mon Sep 17 00:00:00 2001 From: junderw Date: Fri, 10 Nov 2023 23:19:23 -0700 Subject: [PATCH 1/7] Fix gitignore for clippy exercise --- .gitignore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index f319d39..32f3c77 100644 --- a/.gitignore +++ b/.gitignore @@ -3,8 +3,8 @@ target/ **/*.rs.bk .DS_Store *.pdb -exercises/clippy/Cargo.toml -exercises/clippy/Cargo.lock +exercises/22_clippy/Cargo.toml +exercises/22_clippy/Cargo.lock rust-project.json .idea .vscode/* From f2833c5279a139ee5ab747b3dc573946a524349f Mon Sep 17 00:00:00 2001 From: Dan Bond Date: Mon, 18 Mar 2024 16:47:15 -0700 Subject: [PATCH 2/7] options1: Update wording & fix grammar Signed-off-by: Dan Bond --- exercises/12_options/options1.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/exercises/12_options/options1.rs b/exercises/12_options/options1.rs index e131b48..3cbfecd 100644 --- a/exercises/12_options/options1.rs +++ b/exercises/12_options/options1.rs @@ -6,11 +6,11 @@ // I AM NOT DONE // This function returns how much icecream there is left in the fridge. -// If it's before 10PM, there's 5 pieces left. At 10PM, someone eats them +// If it's before 10PM, there's 5 scoops left. At 10PM, someone eats it // all, so there'll be no more left :( fn maybe_icecream(time_of_day: u16) -> Option { // We use the 24-hour system here, so 10PM is a value of 22 and 12AM is a - // value of 0 The Option output should gracefully handle cases where + // value of 0. The Option output should gracefully handle cases where // time_of_day > 23. // TODO: Complete the function body - remember to return an Option! ??? @@ -22,10 +22,11 @@ mod tests { #[test] fn check_icecream() { + assert_eq!(maybe_icecream(0), Some(5)); assert_eq!(maybe_icecream(9), Some(5)); - assert_eq!(maybe_icecream(10), Some(5)); - assert_eq!(maybe_icecream(23), Some(0)); + assert_eq!(maybe_icecream(18), Some(5)); assert_eq!(maybe_icecream(22), Some(0)); + assert_eq!(maybe_icecream(23), Some(0)); assert_eq!(maybe_icecream(25), None); } From eb952a480d2dabcafa8b55e1a89872c9b5e4194b Mon Sep 17 00:00:00 2001 From: Dan Bond Date: Mon, 18 Mar 2024 16:47:54 -0700 Subject: [PATCH 3/7] verify: fix success message spacing Signed-off-by: Dan Bond --- src/verify.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/verify.rs b/src/verify.rs index aee2afa..cafecab 100644 --- a/src/verify.rs +++ b/src/verify.rs @@ -195,7 +195,7 @@ fn prompt_for_completion( if no_emoji { println!("~*~ {success_msg} ~*~") } else { - println!("🎉 🎉 {success_msg} 🎉 🎉") + println!("🎉 🎉 {success_msg} 🎉 🎉") } println!(); From 3df59379de1b3333b911c60b867216690d6c5e1b Mon Sep 17 00:00:00 2001 From: mo8it Date: Wed, 27 Mar 2024 20:28:31 +0100 Subject: [PATCH 4/7] Remove the reference to v1 --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 8fac7a2..6b9c983 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,6 @@ Greetings and welcome to `rustlings`. This project contains small exercises to get you used to reading and writing Rust code. This includes reading and responding to compiler messages! -_...looking for the old, web-based version of Rustlings? Try [here](https://github.com/rust-lang/rustlings/tree/rustlings-1)_ - Alternatively, for a first-time Rust learner, there 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! From 842e341895690aa8d59aab42d6294994ef99d10f Mon Sep 17 00:00:00 2001 From: mo8it Date: Wed, 27 Mar 2024 21:24:36 +0100 Subject: [PATCH 5/7] threads2: simplify threads2 --- exercises/20_threads/threads2.rs | 11 +++++++---- info.toml | 20 ++++++-------------- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/exercises/20_threads/threads2.rs b/exercises/20_threads/threads2.rs index 62dad80..60d6824 100644 --- a/exercises/20_threads/threads2.rs +++ b/exercises/20_threads/threads2.rs @@ -18,7 +18,9 @@ struct JobStatus { } fn main() { + // TODO: `Arc` isn't enough if you want a **mutable** shared state let status = Arc::new(JobStatus { jobs_completed: 0 }); + let mut handles = vec![]; for _ in 0..10 { let status_shared = Arc::clone(&status); @@ -29,11 +31,12 @@ fn main() { }); handles.push(handle); } + + // Waiting for all jobs to complete for handle in handles { handle.join().unwrap(); - // TODO: Print the value of the JobStatus.jobs_completed. Did you notice - // anything interesting in the output? Do you have to 'join' on all the - // handles? - println!("jobs completed {}", ???); } + + // TODO: Print the value of `JobStatus.jobs_completed` + println!("Jobs completed: {}", ???); } diff --git a/info.toml b/info.toml index b1cd64c..36629b3 100644 --- a/info.toml +++ b/info.toml @@ -1136,25 +1136,17 @@ to **immutable** data. But we want to *change* the number of `jobs_completed` so we'll need to also use another type that will only allow one thread to mutate the data at a time. Take a look at this section of the book: https://doc.rust-lang.org/book/ch16-03-shared-state.html#atomic-reference-counting-with-arct -and keep reading if you'd like more hints :) -Do you now have an `Arc` `Mutex` `JobStatus` at the beginning of main? Like: +Keep reading if you'd like more hints :) + +Do you now have an `Arc>` at the beginning of `main`? Like: ``` let status = Arc::new(Mutex::new(JobStatus { jobs_completed: 0 })); ``` -Similar to the code in the example in the book that happens after the text -that says 'Sharing a Mutex Between Multiple Threads'. If not, give that a -try! If you do and would like more hints, keep reading!! - -Make sure neither of your threads are holding onto the lock of the mutex -while they are sleeping, since this will prevent the other thread from -being allowed to get the lock. Locks are automatically released when -they go out of scope. - -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 :)""" +Similar to the code in the following example in the book: +https://doc.rust-lang.org/book/ch16-03-shared-state.html#sharing-a-mutext-between-multiple-threads +""" [[exercises]] name = "threads3" From c6597d0010b869109e4504069d3e1aaa6b6834e6 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Fri, 29 Mar 2024 19:03:57 +0000 Subject: [PATCH 6/7] docs: update AUTHORS.md [skip ci] --- AUTHORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS.md b/AUTHORS.md index 42c7dbf..d82a5ca 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -384,6 +384,7 @@ authors. wznmickey
wznmickey

📖 NicolasRoelandt
NicolasRoelandt

📖 Josh Bouganim
Josh Bouganim

💻 + Dan
Dan

💻 From c2b7f458060e65f7ae041b0b6eb9eaba58eaea1b Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Fri, 29 Mar 2024 19:03:58 +0000 Subject: [PATCH 7/7] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index be95fe9..36952f7 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -2721,6 +2721,15 @@ "contributions": [ "code" ] + }, + { + "login": "loshz", + "name": "Dan", + "avatar_url": "https://avatars.githubusercontent.com/u/3449337?v=4", + "profile": "https://loshz.com", + "contributions": [ + "code" + ] } ], "contributorsPerLine": 8,