Skip to content

Commit 7640633

Browse files
authored
Merge pull request #1901 from zanedp/patch-1
Fix #1900
2 parents e1d1f2c + ecd5114 commit 7640633

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/variable_bindings/declare.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# Declare first
22

3-
It's possible to declare variable bindings first, and initialize them later.
4-
However, this form is seldom used, as it may lead to the use of uninitialized
5-
variables.
3+
It is possible to declare variable bindings first and initialize them later, but all variable bindings must be initialized before they are used: the compiler forbids use of uninitialized variable bindings, as it would lead to undefined behavior.
4+
5+
It is not common to declare a variable binding and initialize it later in the function.
6+
It is more difficult for a reader to find the initialization when initialization is separated from declaration.
7+
It is common to declare and initialize a variable binding near where the variable will be used.
68

79
```rust,editable,ignore,mdbook-runnable
810
fn main() {
@@ -30,5 +32,4 @@ fn main() {
3032
}
3133
```
3234

33-
The compiler forbids use of uninitialized variables, as this would lead to
34-
undefined behavior.
35+

0 commit comments

Comments
 (0)