Skip to content

Commit f1459c5

Browse files
authored
Remove slide on shadowing (#2596)
1 parent 72c7618 commit f1459c5

File tree

3 files changed

+8
-38
lines changed

3 files changed

+8
-38
lines changed

src/SUMMARY.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
- [Solution](types-and-values/solution.md)
3131
- [Control Flow Basics](control-flow-basics.md)
3232
- [Blocks and Scopes](control-flow-basics/blocks-and-scopes.md)
33-
- [Scopes and Shadowing](control-flow-basics/blocks-and-scopes/scopes.md)
3433
- [`if` Expressions](control-flow-basics/if.md)
3534
- [`match` Expressions](control-flow-basics/match.md)
3635
- [Loops](control-flow-basics/loops.md)

src/control-flow-basics/blocks-and-scopes.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ minutes: 5
44

55
# Blocks and Scopes
66

7-
## Blocks
8-
97
A block in Rust contains a sequence of expressions, enclosed by braces `{}`.
108
Each block has a value and a type, which are those of the last expression of the
119
block:
@@ -19,14 +17,22 @@ fn main() {
1917
z - y
2018
};
2119
println!("x: {x}");
20+
// println!("y: {y}");
2221
}
2322
```
2423

2524
If the last expression ends with `;`, then the resulting value and type is `()`.
2625

26+
A variable's scope is limited to the enclosing block.
27+
2728
<details>
2829

2930
- You can show how the value of the block changes by changing the last line in
3031
the block. For instance, adding/removing a semicolon or using a `return`.
3132

33+
- Demonstrate that attempting to access `y` outside of its scope won't compile.
34+
35+
- Values are effectively "deallocated" when they go out of their scope, even if
36+
their data on the stack is still there.
37+
3238
</details>

src/control-flow-basics/blocks-and-scopes/scopes.md

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)