LoginSignup
3
1

More than 3 years have passed since last update.

[Rust] とりあえずHello World!してみた

Posted at

会社の人が学ぶ価値がすごいと言っていたので、
とりあえず Hello World! してみました。

インストール

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

こんなのが表示される。

Welcome to Rust!

This will download and install the official compiler for the Rust
programming language, and its package manager, Cargo.

...

Current installation options:


   default host triple: x86_64-apple-darwin
     default toolchain: stable
               profile: default
  modify PATH variable: yes

1) Proceed with installation (default)
2) Customize installation
3) Cancel installation

デフォルトの1を選択する。

Rust is installed now. Great!

To get started you need Cargo's bin directory ($HOME/.cargo/bin) in your PATH
environment variable. Next time you log in this will be done
automatically.

To configure your current shell run source $HOME/.cargo/env

完了!

動作確認

source $HOME/.cargo/env
rustc --version
rustc 1.42.0 (b8cedc004 2020-03-09)

OK!

Hello World!してみる

ファイルを用意してrustcコマンドでコンパイルする。

hello.rs
fn main() {
    println!("Hello World!");
}
rustc hello.rs

出力されたバイナリファイルを実行する。

./hello

すると、、、

Hello World!

簡単!!!

まとめ

実行環境の構築はびっくりするほど簡単でした。
学習コストは高いがそれに見合うものがある
とのことなので挑戦してみようかと思います。

参考

3
1
2

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
3
1