メインコンテンツまでスキップ
Data SubmissionDatabaseSupercomputerActivitiesAbout Us

Rustの使い方

Rust処理系のインストール#

Rustのインストールはユーザー権限で可能なので、各自必要なバージョンを自分のホームディレクトリにインストールしてください。

公式ホームページ rustup.rs - The Rust toolchain installer にアクセスすると以下のような画面が表示されます。

figure

指示に従ってたった一行をコピーして端末に貼り付け実行すればインストールされます。

  • インストール先は$HOME/.rustup, $HOME/.cargoです。

  • Rustのツールにパス等を通し使えるようにするには、source $HOME/.cargo/envを実行してください。

このスクリプトの実行については自動的に.bashrcに一行追加されます。

user01@266fb189884e:~/public_html/docsify_notes/doc_rust001/section02/p2021_0509_RustCompiler (2021-05-09 01:28:28)$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | shcurl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | shinfo: downloading installer
Welcome to Rust!(BThis will download and install the official compiler for the Rustprogramming language, and its package manager, Cargo.
Rustup metadata and toolchains will be installed into the Rustuphome directory, located at:
  /home/user01/.rustup  This can be modified with the RUSTUP_HOME environment variable.  The Cargo home directory located at:    /home/user01/.cargo    This can be modified with the CARGO_HOME environment variable.    The cargo(B, rustc(B, rustup(B and other commands will be added toCargo's bin directory, located at:      /home/user01/.cargo/bin      This path will then be added to your PATH(B environment variable bymodifying the profile files located at:         /home/user01/.profile   /home/user01/.bashrc          You can uninstall at any time with rustup self uninstall(B andthese changes will be reverted.          Current installation options:                      (Bdefault host triple: x86_64-unknown-linux-gnu(B    (Bdefault toolchain: stable (default)(B              (Bprofile: default(B   modify PATH variable: yes(B                                   1) Proceed with installation (default)2) Customize installation3) Cancel installation>11                                   info: (Bprofile set to 'default'info: (Bdefault host triple is x86_64-unknown-linux-gnuinfo: (Bsyncing channel updates for 'stable-x86_64-unknown-linux-gnu'info: (Blatest update on 2021-05-06, rust version 1.52.0 (88f19c6da 2021-05-03)info: (Bdownloading component 'cargo'info: (Bdownloading component 'clippy'info: (Bdownloading component 'rust-docs' 15.3 MiB /  15.3 MiB (100 %)   7.6 MiB/s in  2s ETA:  0sinfo: (Bdownloading component 'rust-std' 24.1 MiB /  24.1 MiB (100 %)   7.6 MiB/s in  3s ETA:  0sinfo: (Bdownloading component 'rustc' 48.7 MiB /  48.7 MiB (100 %)   7.3 MiB/s in  6s ETA:  0sinfo: (Bdownloading component 'rustfmt'info: (Binstalling component 'cargo'info: (Busing up to 500.0 MiB of RAM to unpack components  6.0 MiB /   6.0 MiB (100 %)   4.1 MiB/s in  1s ETA:  0sinfo: (Binstalling component 'clippy'info: (Binstalling component 'rust-docs' 15.3 MiB /  15.3 MiB (100 %)  12.4 MiB/s in  1s ETA:  0sinfo: (Binstalling component 'rust-std' 24.1 MiB /  24.1 MiB (100 %)   5.7 MiB/s in  3s ETA:  0sinfo: (Binstalling component 'rustc' 48.7 MiB /  48.7 MiB (100 %)   3.6 MiB/s in 12s ETA:  0sinfo: (Binstalling component 'rustfmt'info: (Bdefault toolchain set to 'stable-x86_64-unknown-linux-gnu'                                             stable-x86_64-unknown-linux-gnu installed(B - rustc 1.52.0 (88f19c6da 2021-05-03)                                                                                          Rust is installed now. Great!(BTo get started you may need to restart your current shell.This would reload your PATH(B environment variable to includeCargo's bin directory ($HOME/.cargo/bin).                                             To configure your current shell, run:source $HOME/.cargo/envuser01@266fb189884e:~/public_html/docsify_notes/doc_rust001/section02/p2021_0509_RustCompiler (2021-05-09 01:29:33)$ 

以下のツールがインストールされます。

  • cargo is Rust’s compilation manager, package manager, and general-purpose tool. You can use Cargo to start a new project, build and run your program, and manage any external libraries your code depends on.

  • rustc is the Rust compiler. Usually we let Cargo invoke the compiler for us, but sometimes it’s useful to run it directly.

  • rustdoc is the Rust documentation tool. If you write documentation in comments of the appropriate form in your program’s source code, rustdoc can build nicely formatted HTML from them. Like rustc, we usually let Cargo run rustdoc for us.

に最終更新