Skip to content

Commit cb32f06

Browse files
committed
Rewrite freeze.md
1 parent 0465376 commit cb32f06

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

src/SUMMARY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
- [Mutability](variable_bindings/mut.md)
2828
- [Scope and Shadowing](variable_bindings/scope.md)
2929
- [Declare first](variable_bindings/declare.md)
30+
- [Freezing](variable_bindings/freeze.md)
3031

3132
- [Types](types.md)
3233
- [Casting](types/cast.md)
@@ -117,7 +118,6 @@
117118
- [Mutability](scope/move/mut.md)
118119
- [Borrowing](scope/borrow.md)
119120
- [Mutability](scope/borrow/mut.md)
120-
- [Freezing](scope/borrow/freeze.md)
121121
- [Aliasing](scope/borrow/alias.md)
122122
- [The ref pattern](scope/borrow/ref.md)
123123
- [Lifetimes](scope/lifetime.md)

src/scope/borrow/freeze.md renamed to src/variable_bindings/freeze.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
11
# Freezing
22

3-
When data is immutably borrowed, it also *freezes*. *Frozen* data can't be
4-
modified via the original object until all references to it go out of scope:
3+
When data is bound by the same name immutably, it also *freezes*. *Frozen* data can't be
4+
modified until the immutable binding goes out of scope:
55

66
```rust,editable,ignore,mdbook-runnable
77
fn main() {
88
let mut _mutable_integer = 7i32;
99
1010
{
11-
// Borrow `_mutable_integer`
12-
let large_integer = &_mutable_integer;
11+
// Shadowing by immutable `_mutable_integer`
12+
let _mutable_integer = _mutable_integer;
1313
1414
// Error! `_mutable_integer` is frozen in this scope
1515
_mutable_integer = 50;
1616
// FIXME ^ Comment out this line
1717
18-
println!("Immutably borrowed {}", large_integer);
19-
20-
// `large_integer` goes out of scope
18+
// `_mutable_integer` goes out of scope
2119
}
2220
2321
// Ok! `_mutable_integer` is not frozen in this scope

0 commit comments

Comments
 (0)