From 10d40c59a581c66d8ecd29ad18d410bf97ed524d Mon Sep 17 00:00:00 2001 From: Arthur Milchior Date: Sat, 7 May 2022 03:45:07 +0200 Subject: [PATCH] Introducing init/uninit before its use (#355) --- src/checked-uninit.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/checked-uninit.md b/src/checked-uninit.md index 59badcc..37cbea2 100644 --- a/src/checked-uninit.md +++ b/src/checked-uninit.md @@ -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: