Rust

From ArchWiki
Revision as of 17:15, 17 April 2015 by LysanderAkili (talk | contribs) (rust wiki does not exist. I would like to start a page with simple quick format.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

zh-CN:Rust

From Official website[1]:

Rust is a systems programming language that runs blazingly fast, prevents almost all crashes, and eliminates data races. It is designed to be a safe, concurrent, practical language.
Note: There are three different versions; stable*, beta, and nightly. Nightly is highly recommended.
*Stable is not out for another month.

Installation

There are four ways you can install the package.

1. Obtain the tar[2] package from official website.
2. Obtain the package from the AUR[3].
3. Last but not the least, you can get nighly build from github[4].
4. Lastly, my preference is to obtain the bash script from github[5]. It handles three different versions with neat tools to switch the latter of three. Not just that, it can do nightly updates by running a bash script. Plus, it downloads, and install cargo which is a highly valuable tool for rust language. This is the easiest way.

Quickstart

All files are save as .rs. Let's create a file main.rs in src folder.

fn main() {
	println!("Hello World");
}

Two ways you could run this script; rustc or compile by using cargo build.

1. rustc main.rs

a. If it return blank, it works.

2. Write Cargo.toml

a. run cargo build
b. if successful, there shouldn't be compile errors
c. run ./main, and it should say hello world.

Congrats! You are rusty.

Docs

Nightly Docs[6]

Beta Docs[7]