From d3fd0410c1f282bb15dd1b3b7af8a40170bcf488 Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" Date: Thu, 16 Feb 2017 15:14:28 -0500 Subject: [PATCH] Add a sidebar about uninitialized variables --- src/ch10-03-lifetime-syntax.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/ch10-03-lifetime-syntax.md b/src/ch10-03-lifetime-syntax.md index 427d6e0e8..eaf26923b 100644 --- a/src/ch10-03-lifetime-syntax.md +++ b/src/ch10-03-lifetime-syntax.md @@ -50,6 +50,13 @@ Listing 10-16: An attempt to use a reference whose value has gone out of scope +> #### Uninitialized Variables Cannot Be Used +> +> The next few examples declare variables without giving them an initial value, +> so that the variable name exists in the outer scope. This might appear to be +> in conflict with Rust not having null. However, if we try to use a variable +> before giving it a value, we'll get a compile-time error. Try it out! + When we compile this code, we'll get an error: ```text