LoginSignup
12
7

More than 5 years have passed since last update.

Rustを3時間勉強したらわかること

Last updated at Posted at 2019-03-03

僕が先に3時間分くらい勉強しときました。大体こんな感じっていうのと、読んでよかった記事のリンクを貼っとくので、3時間分くらいショートカットしましょう!

どんなもの?

速いし、並行性もいい感じだし、安全なものが作れる。安全じゃない書き方をすると、コンパイラがちゃんと怒ってくれて、さらに親切なアドバイスをくれる。

エラーの例

⋊> cargo run
   Compiling variables v0.1.0 (/Users/yujiroarai/Projects/variables)
error[E0384]: cannot assign twice to immutable variable `x`
 --> src/main.rs:4:5
  |
2 |     let x = 5;
  |         -
  |         |
  |         first assignment to `x`
  |         help: make this binding mutable: `mut x`
3 |     println!("The value of x is: {}", x);
4 |     x = 6;
  |     ^^^^^ cannot assign twice to immutable variable

何ができるの?

コマンドラインツールもwebアプリもWebAssemblyもラズパイで動くものも作れる。なんでもできる。

こんなとこでつかってる

0からhello worldまで


# インストール(rustupをインストールする)
$ curl https://sh.rustup.rs -sSf | sh
$ source $HOME/.cargo/env # パスを読み込み

# インストールできてるか確認(バージョンが表示されればOK!)
$ rustc --version
rustc 1.33.0 (2aa4c46cf 2019-02-28)

# ソースコード作成
$ vi main.rs
fn main() {
    println!("Hello, world!");
}

# コンパイル
$ rustc main.rs

# 実行
$ ./main
Hello, world!

周辺ツールはどんな感じ?

デフォルトで色々揃えてくれてる!モダンな開発環境がデフォルト。

  • Cargo: 依存関係の管理・ビルドツール
  • Rustfmt: コードフォーマッター
  • Rust Language Server: IDEでエラー表示とコード補完ができるようにする
  • rustup: Rubyのrbenvとか、nodejsのnみたいなRustのバージョンと関連するツールを管理するツール

Rustが好きになる記事

Goと比較してる記事もよく見る

終わり

もうちょっと勉強したら、もっと良い記事書きます!

12
7
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
12
7