Rust Book 学习记录(Nightly)
2.1 安装 2.2 Hello, world! 2.3 Cargo! 2.4 变量 2.5 if 2.6 函数 2.7 注释 0.0 2.1 安装 2.2 Hello, world! 2.3 Cargo! 2.4 变量 2.5 if 2.6 函数 2.7 注释 2.1 安装 $ curl -L https://static.rust-lang.org/rustup.sh | sudo sh 2.2 Hello, world! 创建项目 $ mkdir ~/projects $ cd ~/projects $ mkdir hello_world $ cd hello_world 创建 main.rs,当前目录结构 projects/ └── hello_world └── main.rs 编写代码 fn main() { println!("Hello, world!"); } 在终端编译 main.rs $ rustc main.rs // 编译 现在我们的工程目录变成了这样 projects/ └── hello_world ├── main // 可执行文件 └── main.rs 执行 main,可以看到输出的 “Hello, world!”。 $ ./main # or main.exe on Windows // 运行生成的 main 执行文件 Hello, world