Rustプログラミングの始め方。

公式ページはこちら。

The Rust Guide

こちらの公式のガイドに沿って始めます。Max OS X 10.9.5で試します。

まずはRustをインストールします。

$ curl -s https://static.rust-lang.org/rustup.sh | sudo sh

ダウンロードに時間がかかりますが、待ちます。

インストールが終わったらバージョンを確認。

$ rustc --version
rustc 0.13.0-nightly (c46812f65 2014-10-19 00:47:18 +0000)

適当にディレクトリを作成して、Hello Worldしてみる。

mkdir rust_hello_workd
cd rust_hello_world

rust_hello_world.rsファイルを作成して、テキストエディタで以下のように書く。

fn main() {
  println!("Hello, world!");
}

printlnに!が付いているのはMacroらしいですが、今は気にしないでおく。

コンパイルする。

rustc rust_hello_world.rs

実行可能なrust_hello_worldファイルができあがるので、それを実行する。

$ ./rust_hello_world
Hello, world!

できました。

广告
将在 10 秒后关闭
bannerAds