LoginSignup
1
1

More than 5 years have passed since last update.

Rustのチュートリアルを少しだけやってみる

Last updated at Posted at 2017-01-24

Rustのチュートリアル

Rustとは、、、

Rust(ラスト)は並列かつマルチパラダイムのプログラミング言語である。Mozillaによって開発されている。関数型プログラミング、並列アクターモデル、手続き型プログラミング、オブジェクト指向プログラミングをサポートする実用的な言語を目指している。 (wikiより引用)

インストール

インストールする環境は、Macのbrewがインストールされていることを前提としてます。

$ brew install rust

確認

正常にインストールされたか確認します。
rustcはコンパイル時に利用するものです。
cargoはRustのビルドシステムです。コードのビルド、コードが依存するライブラリのダウンロード、ライブラリのビルドを管理してくれます。

$ rustc -V
rustc 1.14.0
$ cargo -V
cargo 0.15.0-dev (298a012 2016-12-20)

Hello,worldの表示

チュートリアルの基本であるHello,Worldを出力させます。

$cargo new guessing_game --bin

cargoを利用することによって、Cargo.tomlとsrcが作成されます。ソースコードは、srcの中のmain.rsは以下のようになっています。
cargoを利用することによって、自動的に作れられています。

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

それでは実行をしてみます。

$cd guessing_game
$cargo build
$cargo run
Hello, world!

ちゃんとHello,world!が表示されました。

参考

1.https://ja.wikipedia.org/wiki/Rust_(プログラミング言語)
2.https://doc.rust-lang.org/book/README.html

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1