summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormo8it <mo8it@proton.me>2024-05-25 16:31:21 +0200
committermo8it <mo8it@proton.me>2024-05-25 16:31:21 +0200
commit990c68efcba8e1e2b7f2d8c5b6c16885d3920010 (patch)
tree1b9e739b4eabee99db3f076505924cb2c00cf977
parent8d4145038d8b1a2a31314669cc17dc42b1c8e616 (diff)
primitive_types1 solution
-rw-r--r--exercises/04_primitive_types/primitive_types1.rs8
-rw-r--r--rustlings-macros/info.toml5
-rw-r--r--solutions/04_primitive_types/primitive_types1.rs12
3 files changed, 18 insertions, 7 deletions
diff --git a/exercises/04_primitive_types/primitive_types1.rs b/exercises/04_primitive_types/primitive_types1.rs
index 0002651..750d6e5 100644
--- a/exercises/04_primitive_types/primitive_types1.rs
+++ b/exercises/04_primitive_types/primitive_types1.rs
@@ -1,14 +1,12 @@
-// Fill in the rest of the line that has code missing!
-
fn main() {
- // Booleans (`bool`)
-
let is_morning = true;
if is_morning {
println!("Good morning!");
}
- let // Finish the rest of this line like the example! Or make it be false!
+ // TODO: Define a boolean variable with the name `is_evening` before the `if` statement below.
+ // The value of the variable should be the negation (opposite) of `is_morning`.
+ // let …
if is_evening {
println!("Good evening!");
}
diff --git a/rustlings-macros/info.toml b/rustlings-macros/info.toml
index 39fc5c4..59de7f2 100644
--- a/rustlings-macros/info.toml
+++ b/rustlings-macros/info.toml
@@ -234,7 +234,10 @@ hint = "No hints this time ;)"
name = "primitive_types1"
dir = "04_primitive_types"
test = false
-hint = "No hints this time ;)"
+hint = """
+In Rust, a boolean can be negated using the operator `!` before it.
+Example: `!true == false`
+This also works with boolean variables."""
[[exercises]]
name = "primitive_types2"
diff --git a/solutions/04_primitive_types/primitive_types1.rs b/solutions/04_primitive_types/primitive_types1.rs
index 4e18198..fac6ec0 100644
--- a/solutions/04_primitive_types/primitive_types1.rs
+++ b/solutions/04_primitive_types/primitive_types1.rs
@@ -1 +1,11 @@
-// Solutions will be available before the stable release. Thank you for testing the beta version 🥰
+fn main() {
+ let is_morning = true;
+ if is_morning {
+ println!("Good morning!");
+ }
+
+ let is_evening = !is_morning;
+ if is_evening {
+ println!("Good evening!");
+ }
+}