Skip to content

Commit

Permalink
Introducing init/uninit before its use (rust-lang#355)
Browse files Browse the repository at this point in the history
  • Loading branch information
Arthur-Milchior authored May 7, 2022
1 parent eaa3a92 commit 10d40c5
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/checked-uninit.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ fn main() {
```

This is based off of a basic branch analysis: every branch must assign a value
to `x` before it is first used. Interestingly, Rust doesn't require the variable
to `x` before it is first used. For short, we also say that "`x` is init" or
"`x` is uninit".

Interestingly, Rust doesn't require the variable
to be mutable to perform a delayed initialization if every branch assigns
exactly once. However the analysis does not take advantage of constant analysis
or anything like that. So this compiles:
Expand Down

0 comments on commit 10d40c5

Please sign in to comment.