那時候才1.18.0
2017/08/31就發布1.20.0了OAO
$ rustup update stable$ vim main.rsfn main() {
println!("Hello, world!");
}在main.rs
$ rustc main.rs
$ ./main
Hello, world!儲存後退出(:wq)
$ cargo new hello_cargo --bin
$ cd hello_cargo
$ vim src/main.rsfn main() {
println!("Hello, world!");
}在src/main.rs
新增專案
$ cargo build # 建置
$ cargo run # 建置並執行執行
fn main() {
let x = 5;
println!("The value of x is: {}", x);
x = 6;
println!("The value of x is: {}", x);
}用 let 宣告的是不可變
error[E0384]: re-assignment of immutable variable `x`
--> src/main.rs:4:5
|
2 | let x = 5;
| - first assignment to `x`
3 | println!("The value of x is: {}", x);
4 | x = 6;
| ^^^^^ re-assignment of immutable variable