diff --git a/.all-contributorsrc b/.all-contributorsrc index 91b2a486..8207a035 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -1074,6 +1074,24 @@ "contributions": [ "content" ] + }, + { + "login": "sundevilyang", + "name": "Yang Wen", + "avatar_url": "https://avatars.githubusercontent.com/u/1499214?v=4", + "profile": "https://github.com/sundevilyang", + "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, diff --git a/README.md b/README.md index 6fe96b57..c9bb8b87 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-118-orange.svg?style=flat-square)](#contributors-) # rustlings 🦀❤️ @@ -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. @@ -322,6 +323,8 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
Franklin van Nes

💻
nekonako

💻
ZX

🖋 +
Yang Wen

🖋 +
Brandon High

📖 diff --git a/exercises/error_handling/errors1.rs b/exercises/error_handling/errors1.rs index 109d7a10..3f11e108 100644 --- a/exercises/error_handling/errors1.rs +++ b/exercises/error_handling/errors1.rs @@ -33,6 +33,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()) ); } 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..1c4582de --- /dev/null +++ b/exercises/intro/intro1.rs @@ -0,0 +1,23 @@ +// 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#" |___/ "#); + 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!"); +} 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/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 48f1febf..55d9a975 100644 --- a/exercises/option/option1.rs +++ b/exercises/option/option1.rs @@ -1,7 +1,13 @@ // option1.rs // Make me compile! Execute `rustlings hint option1` for hints +<<<<<<< HEAD // you can modify anything EXCEPT for this function's sig +======= +// I AM NOT DONE + +// you can modify anything EXCEPT for this function's signature +>>>>>>> upstream/main fn print_number(maybe_number: Option) { println!("printing: {}", maybe_number.unwrap()); } diff --git a/exercises/structs/structs3.rs b/exercises/structs/structs3.rs index 506ad301..de48b925 100644 --- a/exercises/structs/structs3.rs +++ b/exercises/structs/structs3.rs @@ -14,7 +14,11 @@ struct Package { impl Package { fn new(sender_country: String, recipient_country: String, weight_in_grams: i32) -> Package { if weight_in_grams <= 0 { +<<<<<<< HEAD panic!("Attempted to construct a package with negative weight"); +======= + // panic statement goes here... +>>>>>>> upstream/main } else { Package { sender_country, diff --git a/exercises/variables/variables1.rs b/exercises/variables/variables1.rs index db85e7e4..f41da792 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 :) fn main() { let x = 5; diff --git a/info.toml b/info.toml index 0c03def3..fbe0d53b 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]] 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" 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() } }