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 1/2] 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 0000000000..d32e4a8bf2 --- /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 0000000000..83a78e68ff --- /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 0000000000..97a073f0e0 --- /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 4a3af73c08..d1af831172 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 82e119522d..c56b19fdad 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 2/2] 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 83a78e68ff..1c4582dec7 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!"); }