Rust guarantees memory safety at compile time. As a part of that variables must be initialized before you can use them. This code won't work because Enigma has been declared but not initialized to a value before we try to use it. In fact, it won't even compile, we get the error, use of possibly uninitialized variable and nygma. What if we might initialize the nygma depending on some condition, the compiler won't reason about the value of a condition at compile time, even if it's a literal, true or false. Conditional evaluation is handled at runtime.
So the compiler can't guarantee that Enigma will be initialized before it is used because the compiler doesn't know what the value of true will be at runtime. So this still won't work. But this works. The compiler can tell the Enigma is guaranteed to be initialized before it is used. As long as As the compiler can guarantee something is safe, it will let you do it. What if you tried the same thing and see what if you declared a variable and then used it before initializing it?
Welcome to the glorious realm of undefined behavior on my Mac. I tried it and then I got the number one. I'm not sure if that's just what happened to me memory or what but your mileage may vary because your compiler can choose to do anything it wants to do in this situation. Let's leave C and its craziness alone. In the next video, we will go over functions