Rust 中变量和常量的概念,变量分为可变变量和不可变变量,常量用 const 定义。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| fn main() { println!("/////////////////////////////////////////"); println!("==============Hello, world!=============="); println!("/////////////////////////////////////////");
let x = 5; let y: f64 = 12.325; let mut z: f64;
println!("x: {x}"); println!("y: {y}"); z = 100.0; z = (x as f64) + y + z; println!("z: {z}");
let x = "Hello"; println!("x: {x}");
const PI: f64 = 3.14; println!("PI: {PI}");
}
|