The Rust Ecosystem

Rustエコシステムの主要ツールは以下の通りです:

  • rustc: Rustのコンパイラです。.rsファイルをバイナリや他の中間形式に変換します。

  • cargo: the Rust dependency manager and build tool. Cargo knows how to download dependencies, usually hosted on https://crates.io, and it will pass them to rustc when building your project. Cargo also comes with a built-in test runner which is used to execute unit tests.

  • rustup: the Rust toolchain installer and updater. This tool is used to install and update rustc and cargo when new versions of Rust are released. In addition, rustup can also download documentation for the standard library. You can have multiple versions of Rust installed at once and rustup will let you switch between them as needed.

要点:

  • Rust言語とコンパイラは、6週間のリリースサイクルを採用しています。新しいリリースは、古いリリースとの後方互換性を維持しながら、新機能を提供します。

  • リリースチャネルは3つあります:「stable」「beta」「nightly」。

  • 新機能は「nightly」でテストされ、「beta」が6週間毎に「stable」となります。

  • Dependencies can also be resolved from alternative registries, git, folders, and more.

  • Rustにはeditions(エディション)があります:現在のエディションはRust2021です。以前はRust2015とRust2018でした。

    • エディションでは、後方非互換な変更を加える事ができます。

    • コードの破損を防ぐために、エディションはオプトイン方式です:Cargo.tomlで、クレートに対して適用したいエディションを選択します。

    • エコシステムの分断を避けるために、コンパイラは異なるエディションのコードを混在させる事ができます。

    • コンパイラを直接使用する事は非常に稀であり、基本的にはcargoを介します。

    • It might be worth alluding that Cargo itself is an extremely powerful and comprehensive tool. It is capable of many advanced features including but not limited to:

      • プロジェクト・パッケージの構造管理
      • workspaces(ワークスペース)
      • 開発用とランタイム用の依存関係管理・キャッシュ
      • build scripting(ビルドスクリプト)
      • global installation
      • cargo clippyなどのサブコマンドプラグインによる拡張
    • 詳細はofficial Cargo Bookを参照してください。