rust-ape-example/src/bin/variable_bindings_declare.rs

32 lines
520 B
Rust
Raw Normal View History

// ./src/variable_bindings/declare.md
fn part0() {
// 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
2022-09-07 05:36:14 +00:00
// println!("another binding: {}", another_binding);
// FIXME ^ Comment out this line
another_binding = 1;
println!("another binding: {}", another_binding);
}
pub fn main() {
part0();
}