rust

根據百度百科的解釋:Rust是Mozilla開發的注重安全、性能和併發性的編程語言。rust官網:https://www.rust-lang.org/

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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章