Rustの開発環境を構築します。
rustupのインストール
rustupというツールで環境を構築/管理するのでrustupをインストールします。
https://rustup.rs/
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
info: downloading installer
Welcome to Rust!
This will download and install the official compiler for the Rust programming
language, and its package manager, Cargo.
It will add the cargo, rustc, rustup and other commands to Cargo's bin
directory, located at:
/Users/sallies/.cargo/bin
This path will then be added to your PATH environment variable by modifying the
profile files located at:
/Users/sallies/.profile
/Users/sallies/.bash_profile
You can uninstall at any time with rustup self uninstall and these changes will
be reverted.
Current installation options:
default host triple: x86_64-apple-darwin
default toolchain: stable
modify PATH variable: yes
1) Proceed with installation (default)
2) Customize installation
3) Cancel installation
>1
info: syncing channel updates for 'stable-x86_64-apple-darwin'
334.4 KiB / 334.4 KiB (100 %) 55.1 KiB/s ETA: 0 s
info: latest update on 2019-04-25, rust version 1.34.1 (fc50f328b 2019-04-24)
info: downloading component 'rustc'
78.9 MiB / 78.9 MiB (100 %) 992.5 KiB/s ETA: 0 s
info: downloading component 'rust-std'
51.1 MiB / 51.1 MiB (100 %) 290.6 KiB/s ETA: 0 s
info: downloading component 'cargo'
3.4 MiB / 3.4 MiB (100 %) 437.6 KiB/s ETA: 0 s
info: downloading component 'rust-docs'
10.2 MiB / 10.2 MiB (100 %) 113.4 KiB/s ETA: 0 s
info: installing component 'rustc'
78.9 MiB / 78.9 MiB (100 %) 14.1 MiB/s ETA: 0 s
info: installing component 'rust-std'
51.1 MiB / 51.1 MiB (100 %) 16.9 MiB/s ETA: 0 s
info: installing component 'cargo'
info: installing component 'rust-docs'
10.2 MiB / 10.2 MiB (100 %) 2.0 MiB/s ETA: 0 s
info: default toolchain set to 'stable'
stable installed - rustc 1.34.1 (fc50f328b 2019-04-24)
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
$HOME/.cargo/bin には次のようなファイルがインストールされます。
cargo cargo-clippy cargo-fmt cargo-miri clippy-driver rls rust-gdb rust-lldb rustc rustdoc rustfmt rustup
$HOME/.cargo/env には環境変数の設定が記述されています。
Rust用パッケージを眺める
| パッケージ名 | 説明 |
| cargo | Cargo用のマイナーモード |
| flycheck-rust | Rust用Flycheck |
| flymake-rust | Rust用Flymake |
| lsp-rust | Rust support for lsp-mode |
| ob-rust | Org-babelのRust拡張 |
| racer | racerでRustのコード補完、goto-definition、ドキュメント参照 |
| reason-mode | A major emacs mode for editing Reason (based on rust-mode) |
| rust-auto-use | Rust useステートメントを自動的に挿入するためのユーティリティ |
| rust-playground | Rust用プレイグラウンド |
| rustic | Rust用開発環境パッケージ |
| rust-mode | Rust用メジャーモード |
rust-playground
インストール
(use-package rust-playground :ensure t)パッケージ情報
rust-playground is an available package.
Status: Available from melpa -- Install
Archive: melpa
Version: 20180807.1158
Commit: 092c8b11d62dea23953a004744833092bac85fe1
Summary: Local Rust playground for short code snippets.
Requires: emacs-24.3
Homepage: https://github.com/grafov/rust-playground
Keywords: tools rust
Other versions: 0.3 (melpa-stable).
Local playground for the Rust programs similar to play.rust-lang.org.
`M-x rust-playground` and type you rust code then make&run it with `C-c C-c`.
Toggle between Cargo.toml and main.rs with `C-c b`
Delete the current playground and close all buffers with `C-c k`
Playground requires preconfigured environment for Rust language.
It is port of github.com/grafov/go-playground for Go language.
flycheck-rust
Rust用Flycheckです。
インストール
(use-package flycheck-rust :ensure t)
(with-eval-after-load 'rust-mode
(add-hook 'flycheck-mode-hook #'flycheck-rust-setup))パッケージ情報
flycheck-rust is an installed package.
Status: Installed in ‘flycheck-rust-20190319.1546/’ (unsigned). Delete
Version: 20190319.1546
Commit: a139cd53c5062697e9ed94ad80b803c37d999600
Summary: Flycheck: Rust additions and Cargo support
Requires: emacs-24.1, flycheck-28, dash-2.13.0, seq-2.3, let-alist-1.0.4
Homepage: https://github.com/flycheck/flycheck-rust
Keywords: tools convenience
Other versions: 20190319.1546 (melpa), 1.1 (melpa-stable).
This Flycheck extension configures Flycheck automatically for the current
Cargo project.
# Setup
(with-eval-after-load 'rust-mode
(add-hook 'flycheck-mode-hook #'flycheck-rust-setup))
# Usage
Just use Flycheck as usual in your Rust/Cargo projects.
[back]
cargo
https://github.com/kwrooijen/cargo.el
cargoのショートカットを提供しています。設定されているショートカットは https://github.com/kwrooijen/cargo.el#usage に記載されています。またパッケージ情報にも記載されています。
インストール
(use-package cargo :ensure t)パッケージ情報
cargo is an installed package.
Status: Installed in ‘cargo-20190108.817/’ (unsigned). Delete
Version: 20190108.817
Summary: Emacs Minor Mode for Cargo, Rust's Package Manager.
Requires: emacs-24.3, rust-mode-0.2.0, markdown-mode-2.4
Keywords: tools
Other versions: 20190108.817 (melpa), 0.4.1 (melpa-stable).
Cargo Minor mode.
Provides a number of key combinations and functions for managing Cargo.
Current supported Cargo Key Combinations:
* C-c C-c C-e - cargo-process-bench
* C-c C-c C-b - cargo-process-build
* C-c C-c C-l - cargo-process-clean
* C-c C-c C-d - cargo-process-doc
* C-c C-c C-v - cargo-process-doc-open
* C-c C-c C-n - cargo-process-new
* C-c C-c C-i - cargo-process-init
* C-c C-c C-r - cargo-process-run
* C-c C-c C-x - cargo-process-run-example
* C-c C-c C-s - cargo-process-search
* C-c C-c C-t - cargo-process-test
* C-c C-c C-u - cargo-process-update
* C-c C-c C-c - cargo-process-repeat
* C-c C-c C-f - cargo-process-current-test
* C-c C-c C-o - cargo-process-current-file-tests
* C-c C-c C-m - cargo-process-fmt
* C-c C-c C-k - cargo-process-check
* C-c C-c C-K - cargo-process-clippy