1. 安裝
從官網下載安裝包,我這裏下載的安裝包名字是:rust-1.6.0-x86_64-unknown-linux-gnu.tar.gz
然後解壓,進入rust目錄,根據README提示,執行sudo ./install.sh命令來安裝rust。
2. hello
hello world源碼:
// This is a comment, and will be ignored by the compiler
// You can test this code by clicking the "Run" button over there ->
// or if prefer to use your keyboard, you can use the "Ctrl + Enter" shortcut
// This code is editable, feel free to hack it!
// You can always return to the original code by clicking the "Reset" button ->
// This is the main function
fn main() {
// The statements here will be executed when the compiled binary is called
// Print text to the console
println!("Hello World!");
}
然後編譯,編譯使用rustc命令:
rustc hello.rs
運行:
$ ./hello
Hello World!
參考:http://rustbyexample.com/hello.html