1
0
mirror of https://github.com/rust-lang/rustlings.git synced 2024-11-08 09:09:17 +01:00

primitive_types1 solution

This commit is contained in:
mo8it 2024-05-25 16:31:21 +02:00
parent 8d4145038d
commit 990c68efcb
3 changed files with 18 additions and 7 deletions

@ -1,14 +1,12 @@
// Fill in the rest of the line that has code missing!
fn main() { fn main() {
// Booleans (`bool`)
let is_morning = true; let is_morning = true;
if is_morning { if is_morning {
println!("Good 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 { if is_evening {
println!("Good evening!"); println!("Good evening!");
} }

@ -234,7 +234,10 @@ hint = "No hints this time ;)"
name = "primitive_types1" name = "primitive_types1"
dir = "04_primitive_types" dir = "04_primitive_types"
test = false 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]] [[exercises]]
name = "primitive_types2" name = "primitive_types2"

@ -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!");
}
}