rust-ape-example/src/bin/variable_bindings_declare.rs
2022-09-07 11:36:05 +05:30

31 lines
520 B
Rust

// ./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
// println!("another binding: {}", another_binding);
// FIXME ^ Comment out this line
another_binding = 1;
println!("another binding: {}", another_binding);
}
pub fn main() {
part0();
}