dummy.do: Semicolon elision!

This commit is contained in:
2025-10-17 06:57:37 -04:00
parent db9c75b3c6
commit 75048c61c9

View File

@@ -4,13 +4,13 @@
// This is a function. It can be called with the call operator. // This is a function. It can be called with the call operator.
// The function called `main` is the program's entrypoint // The function called `main` is the program's entrypoint
fn main() /*-> (&str, bool, i128)*/ { fn main() -> (&str, bool, i128) {
// An if expression is like the ternary conditional operator in C // An if expression is like the ternary conditional operator in C
let y = if 10 < 50 { let y = if 10 < 50 {
"\u{1f988}" "\u{1f988}"
} else { } else {
"x" "x"
}; }
// A `while` expression is like the while-else construct in Python, // A `while` expression is like the while-else construct in Python,
// but it returns a value via the `break` keyword // but it returns a value via the `break` keyword
@@ -20,26 +20,28 @@ fn main() /*-> (&str, bool, i128)*/ {
} else { } else {
// If `while` does not `break`, fall through to the `else` expression // If `while` does not `break`, fall through to the `else` expression
false false
}; }
// The same is true of `for` expressions! // The same is true of `for` expressions!
// let w = for idx in 0..100 { let w = for idx in 0..100 {
// if idx > 2 * 2 { if idx > 2 * 2 {
// break idx break idx
// } }
// } else { } else 12345; // semicolon operator required here
// 12345
// };
// desugars to // desugars to
{ let w = match ((0..100).into_iter()) {
let _it = 0..100; __iter => loop match (__iter.next()) {
loop if let idx = _it.next() { None => break 12345,
if idx > 2 * 2 { break idx } Some (idx) => {
} else break { 12345 } if (idx > (2 * 2)) {
break idx
}
},
},
}; };
// A block evaluates to its last expression, // A block evaluates to its last expression,
// or Empty if there is none // or Empty if there is none
// (🦈, false, 5) // (🦈, false, 5)