From 5ecdddf9c82d590544ddd69eb99760bb59cf044d Mon Sep 17 00:00:00 2001 From: Nicole L Date: Fri, 23 Feb 2024 08:53:26 -0800 Subject: [PATCH] Remove tangential text from `if` slide (#1840) --- book.toml | 2 ++ src/SUMMARY.md | 2 +- .../{conditionals.md => if.md} | 16 +++------------- 3 files changed, 6 insertions(+), 14 deletions(-) rename src/control-flow-basics/{conditionals.md => if.md} (71%) diff --git a/book.toml b/book.toml index fd9e1c97202..a45c63787f2 100644 --- a/book.toml +++ b/book.toml @@ -233,6 +233,8 @@ use-boolean-and = true 'unsafe/extern-functions.html' = '../unsafe-rust/unsafe-functions.html' 'unsafe/unsafe-traits.html' = '../unsafe-rust/unsafe-traits.html' 'exercises/day-3/safe-ffi-wrapper.html' = '../../unsafe-rust/exercise.html' +'hello-world/hello-world.html' = '../types-and-values/hello-world.html' +'control-flow-basics/conditionals.html' = 'if.html' [output.exerciser] output-directory = "comprehensive-rust-exercises" diff --git a/src/SUMMARY.md b/src/SUMMARY.md index 17d51fccf6f..13e5e575435 100644 --- a/src/SUMMARY.md +++ b/src/SUMMARY.md @@ -30,7 +30,7 @@ - [Exercise: Fibonacci](types-and-values/exercise.md) - [Solution](types-and-values/solution.md) - [Control Flow Basics](control-flow-basics.md) - - [Conditionals](control-flow-basics/conditionals.md) + - [`if` Expressions](control-flow-basics/if.md) - [Loops](control-flow-basics/loops.md) - [`for`](control-flow-basics/loops/for.md) - [`loop`](control-flow-basics/loops/loop.md) diff --git a/src/control-flow-basics/conditionals.md b/src/control-flow-basics/if.md similarity index 71% rename from src/control-flow-basics/conditionals.md rename to src/control-flow-basics/if.md index 81378ac3332..7f0bcdddedc 100644 --- a/src/control-flow-basics/conditionals.md +++ b/src/control-flow-basics/if.md @@ -2,17 +2,7 @@ minutes: 4 --- -# Conditionals - -Much of the Rust syntax will be familiar to you from C, C++ or Java: - -- Blocks are delimited by curly braces. -- Line comments are started with `//`, block comments are delimited by - `/* ... */`. -- Keywords like `if` and `while` work the same. -- Variable assignment is done with `=`, comparison is done with `==`. - -## `if` expressions +# `if` expressions You use [`if` expressions](https://doc.rust-lang.org/reference/expressions/if-expr.html#if-expressions) @@ -21,8 +11,8 @@ exactly like `if` statements in other languages: ```rust,editable fn main() { let x = 10; - if x < 20 { - println!("small"); + if x == 0 { + println!("zero!"); } else if x < 100 { println!("biggish"); } else {