From 4a384cae4ac735e243bbc58184b1f409e914ddc5 Mon Sep 17 00:00:00 2001 From: Zerotask Date: Sat, 24 Apr 2021 12:12:49 +0200 Subject: [PATCH 01/11] docs(option): improve further information --- exercises/option/README.md | 2 ++ exercises/option/option1.rs | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/exercises/option/README.md b/exercises/option/README.md index a304bb44..89c00289 100644 --- a/exercises/option/README.md +++ b/exercises/option/README.md @@ -16,3 +16,5 @@ Option types are very common in Rust code, as they have a number of uses: - [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/) - [Option Enum Documentation](https://doc.rust-lang.org/std/option/enum.Option.html) +- [if let](https://doc.rust-lang.org/rust-by-example/flow_control/if_let.html) +- [while let](https://doc.rust-lang.org/rust-by-example/flow_control/while_let.html) diff --git a/exercises/option/option1.rs b/exercises/option/option1.rs index 602ff1a9..17cf4f60 100644 --- a/exercises/option/option1.rs +++ b/exercises/option/option1.rs @@ -3,7 +3,7 @@ // I AM NOT DONE -// you can modify anything EXCEPT for this function's sig +// you can modify anything EXCEPT for this function's signature fn print_number(maybe_number: Option) { println!("printing: {}", maybe_number.unwrap()); } From 21c9f44168394e08338fd470b5f49b1fd235986f Mon Sep 17 00:00:00 2001 From: apogeeoak <59737221+apogeeoak@users.noreply.github.com> Date: Sat, 24 Apr 2021 13:15:34 -0400 Subject: [PATCH 02/11] feat(intro): Add intro section. --- exercises/intro/README.md | 8 ++++++++ exercises/intro/intro1.rs | 19 +++++++++++++++++++ exercises/intro/intro2.rs | 9 +++++++++ exercises/variables/variables1.rs | 8 ++------ info.toml | 16 ++++++++++++++++ 5 files changed, 54 insertions(+), 6 deletions(-) create mode 100644 exercises/intro/README.md create mode 100644 exercises/intro/intro1.rs create mode 100644 exercises/intro/intro2.rs diff --git a/exercises/intro/README.md b/exercises/intro/README.md new file mode 100644 index 00000000..d32e4a8b --- /dev/null +++ b/exercises/intro/README.md @@ -0,0 +1,8 @@ +# Intro + +Rust uses the `print!` and `println!` macros to print text to the console. + +## Further information + +- [Hello World](https://doc.rust-lang.org/rust-by-example/hello.html) +- [Formatted print](https://doc.rust-lang.org/rust-by-example/hello/print.html) diff --git a/exercises/intro/intro1.rs b/exercises/intro/intro1.rs new file mode 100644 index 00000000..83a78e68 --- /dev/null +++ b/exercises/intro/intro1.rs @@ -0,0 +1,19 @@ +// intro1.rs +// About this `I AM NOT DONE` thing: +// We sometimes encourage you to keep trying things on a given exercise, even +// after you already figured it out. If you got everything working and feel +// ready for the next exercise, remove the `I AM NOT DONE` comment below. +// Execute the command `rustlings hint intro1` for a hint. + +// I AM NOT DONE + +fn main() { + println!("Hello and"); + println!(r#" welcome to... "#); + println!(r#" _ _ _ "#); + println!(r#" _ __ _ _ ___| |_| (_)_ __ __ _ ___ "#); + println!(r#" | '__| | | / __| __| | | '_ \ / _` / __| "#); + println!(r#" | | | |_| \__ \ |_| | | | | | (_| \__ \ "#); + println!(r#" |_| \__,_|___/\__|_|_|_| |_|\__, |___/ "#); + println!(r#" |___/ "#); +} diff --git a/exercises/intro/intro2.rs b/exercises/intro/intro2.rs new file mode 100644 index 00000000..97a073f0 --- /dev/null +++ b/exercises/intro/intro2.rs @@ -0,0 +1,9 @@ +// intro2.rs +// Make the code print a greeting to the world. +// Execute `rustlings hint intro2` for a hint. + +// I AM NOT DONE + +fn main() { + println!("Hello {}!"); +} diff --git a/exercises/variables/variables1.rs b/exercises/variables/variables1.rs index 4a3af73c..d1af8311 100644 --- a/exercises/variables/variables1.rs +++ b/exercises/variables/variables1.rs @@ -1,10 +1,6 @@ // variables1.rs -// Make me compile! Execute the command `rustlings hint variables1` if you want a hint :) - -// About this `I AM NOT DONE` thing: -// We sometimes encourage you to keep trying things on a given exercise, -// even after you already figured it out. If you got everything working and -// feel ready for the next exercise, remove the `I AM NOT DONE` comment below. +// Make me compile! +// Execute the command `rustlings hint variables1` if you want a hint :) // I AM NOT DONE diff --git a/info.toml b/info.toml index 82e11952..c56b19fd 100644 --- a/info.toml +++ b/info.toml @@ -1,3 +1,19 @@ +# INTRO + +[[exercises]] +name = "intro1" +path = "exercises/intro/intro1.rs" +mode = "compile" +hint = """ +Remove the I AM NOT DONE comment to move on to the next exercise.""" + +[[exercises]] +name = "intro2" +path = "exercises/intro/intro2.rs" +mode = "compile" +hint = """ +Add an argument after the format string.""" + # VARIABLES [[exercises]] From 9b8de65525a5576b78cf0c8e4098cdd34296338f Mon Sep 17 00:00:00 2001 From: apogeeoak <59737221+apogeeoak@users.noreply.github.com> Date: Mon, 26 Apr 2021 20:28:17 -0400 Subject: [PATCH 03/11] fix(intro1): Add compiler error explanation. --- exercises/intro/intro1.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/exercises/intro/intro1.rs b/exercises/intro/intro1.rs index 83a78e68..1c4582de 100644 --- a/exercises/intro/intro1.rs +++ b/exercises/intro/intro1.rs @@ -16,4 +16,8 @@ fn main() { println!(r#" | | | |_| \__ \ |_| | | | | | (_| \__ \ "#); println!(r#" |_| \__,_|___/\__|_|_|_| |_|\__, |___/ "#); println!(r#" |___/ "#); + println!(); + println!("This exercise compiles successfully. The remaining exercises contain a compiler"); + println!("or logic error. The central concept behind Rustlings is to fix these errors and"); + println!("solve the exercises. Good luck!"); } From 71a06044e6a96ff756dc31d7b0ed665ae4badb57 Mon Sep 17 00:00:00 2001 From: radicale Date: Fri, 4 Feb 2022 14:39:09 +0100 Subject: [PATCH 04/11] fix(clippy1): Set clippy::float_cmp lint to deny (#907) --- src/exercise.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/exercise.rs b/src/exercise.rs index e4a4145d..6e49a9aa 100644 --- a/src/exercise.rs +++ b/src/exercise.rs @@ -154,7 +154,7 @@ path = "{}.rs""#, Command::new("cargo") .args(&["clippy", "--manifest-path", CLIPPY_CARGO_TOML_PATH]) .args(RUSTC_COLOR_ARGS) - .args(&["--", "-D", "warnings"]) + .args(&["--", "-D", "warnings","-D","clippy::float_cmp"]) .output() } } From cbcde345409c3e550112e449242848eaa3391bb6 Mon Sep 17 00:00:00 2001 From: zydxhs Date: Fri, 4 Feb 2022 22:00:24 +0800 Subject: [PATCH 05/11] fix(errors1): Add a comment to make the purpose more clear (#486) Signed-off-by: zydxhs --- exercises/error_handling/errors1.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/exercises/error_handling/errors1.rs b/exercises/error_handling/errors1.rs index 9c24d85d..5844a497 100644 --- a/exercises/error_handling/errors1.rs +++ b/exercises/error_handling/errors1.rs @@ -36,6 +36,7 @@ mod tests { fn explains_why_generating_nametag_text_fails() { assert_eq!( generate_nametag_text("".into()), + // Don't change this line Err("`name` was empty; it must be nonempty.".into()) ); } From 4f7ff5d9c7b2d8b045194c1a9469d37e30257c4a Mon Sep 17 00:00:00 2001 From: Yang Wen Date: Fri, 4 Feb 2022 22:12:02 +0800 Subject: [PATCH 06/11] fix(structs3): Add a hint for panic (#608) as a totally newbie to Rust, I don't know panic statement from https://doc.rust-lang.org/book/ and rustlings in the beginning. After a hard searching of [should_panic], then I figure out panic statement. So it's helpful to tell the learner that write a panic statement here. --- 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 1a81531c..e84f2ebc 100644 --- a/exercises/structs/structs3.rs +++ b/exercises/structs/structs3.rs @@ -16,7 +16,7 @@ struct Package { impl Package { fn new(sender_country: String, recipient_country: String, weight_in_grams: i32) -> Package { if weight_in_grams <= 0 { - // Something goes here... + // panic statement goes here... } else { Package { sender_country, From 52c7f8a85901b6714c732d2107823750de0d452f Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Fri, 4 Feb 2022 14:13:31 +0000 Subject: [PATCH 07/11] 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 6fe96b57..b4f6a7ee 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -[![All Contributors](https://img.shields.io/badge/all_contributors-116-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-117-orange.svg?style=flat-square)](#contributors-) # rustlings 🦀❤️ @@ -322,6 +322,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Franklin van Nes

💻
nekonako

💻
ZX

🖋 +
Yang Wen

🖋 From a2e74a2a4bebdd48e9c4336c08c02222e36e2e6d Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Fri, 4 Feb 2022 14:13:32 +0000 Subject: [PATCH 08/11] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 91b2a486..3f246446 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -1074,6 +1074,15 @@ "contributions": [ "content" ] + }, + { + "login": "sundevilyang", + "name": "Yang Wen", + "avatar_url": "https://avatars.githubusercontent.com/u/1499214?v=4", + "profile": "https://github.com/sundevilyang", + "contributions": [ + "content" + ] } ], "contributorsPerLine": 8, From bc5686174463ad6f4f6b824b0e9b97c3039d4886 Mon Sep 17 00:00:00 2001 From: Brandon High Date: Fri, 4 Feb 2022 06:38:55 -0800 Subject: [PATCH 09/11] doc: Add hints on how to get gcc installed (#741) --- README.md | 1 + install.sh | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/README.md b/README.md index b4f6a7ee..835200e8 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ Alternatively, for a first-time Rust learner, there are several other resources: ## Getting Started _Note: If you're on MacOS, make sure you've installed Xcode and its developer tools by typing `xcode-select --install`._ +_Note: If you're on Linux, make sure you've installed gcc. Deb: `sudo apt install gcc`. Yum: `sudo yum -y install gcc`._ You will need to have Rust installed. You can get it by visiting https://rustup.rs. This'll also install Cargo, Rust's package/project manager. diff --git a/install.sh b/install.sh index e986e741..68b8da3a 100755 --- a/install.sh +++ b/install.sh @@ -12,6 +12,18 @@ else exit 1 fi +if [ -x "$(command -v cc)" ] +then + echo "SUCCESS: cc is installed" +else + echo "ERROR: cc does not seem to be installed." + echo "Please download (g)cc using your package manager." + echo "OSX: xcode-select --install" + echo "Deb: sudo apt install gcc" + echo "Yum: sudo yum -y install gcc" + exit 1 +fi + if [ -x "$(command -v rustc)" ] then echo "SUCCESS: Rust is installed" From e96112ab998f6b121b2ea7ddf27d9e99e37dba0f Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Fri, 4 Feb 2022 14:39:42 +0000 Subject: [PATCH 10/11] 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 835200e8..c9bb8b87 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -[![All Contributors](https://img.shields.io/badge/all_contributors-117-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-118-orange.svg?style=flat-square)](#contributors-) # rustlings 🦀❤️ @@ -324,6 +324,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
nekonako

💻
ZX

🖋
Yang Wen

🖋 +
Brandon High

📖 From dc36ca6d84e66e1304f662770d560b3fcde7c35d Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Fri, 4 Feb 2022 14:39:43 +0000 Subject: [PATCH 11/11] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 3f246446..8207a035 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -1083,6 +1083,15 @@ "contributions": [ "content" ] + }, + { + "login": "highb", + "name": "Brandon High", + "avatar_url": "https://avatars.githubusercontent.com/u/759848?v=4", + "profile": "https://brandon-high.com", + "contributions": [ + "doc" + ] } ], "contributorsPerLine": 8,