Rust变量绑定-声明
fn main() { // Declare a variable binding let a_binding; { let x = 2; // Initialize the binding a_binding = x * x; } println!("a binding: {}", a_binding); let another_binding; // Error! Use of uninitialized binding println!("another binding: {}", another_binding); // FIXME ^ Comment out this line another_binding = 1; println!("another binding: {}", another_binding); }编译器禁止使用未初始化变量,因为这将导致不确定的行为。