mirror of
https://github.com/ahgamut/rust-ape-example.git
synced 2024-11-25 01:01:01 +00:00
31 lines
520 B
Rust
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();
|
|
}
|
|
|