| 開発中にやりたいこと | 参照ページ |
|---|---|
| Rustプログラムをビルド・実行したい | Cargo |
| テストやClippy(静的解析)を実行したい | Cargo |
| 外部クレートを追加・更新したい | Cargo |
| コンパイルエラーを詳しく調べたい | rustc |
| アセンブリやLLVM IRを確認したい | rustc |
| 最適化やデバッグ情報を制御したい | rustc |
| Rustのバージョンを更新したい | rustup |
| StableとNightlyを切り替えたい | rustup |
| WindowsやARM向けビルド環境を準備したい | rustup |
| コマンド | 用途 |
|---|---|
cargo new |
プロジェクト作成 |
cargo init |
既存ディレクトリ初期化 |
cargo check |
高速コンパイルチェック |
cargo build |
ビルド |
cargo run |
実行 |
cargo test |
テスト |
cargo fmt |
コード整形 |
cargo clippy |
静的解析 |
cargo clean |
成果物削除 |
cargo add |
依存追加 |
cargo remove |
依存削除 |
cargo update |
依存バージョン再解決 |
cargo tree |
依存関係調査 |
cargo metadata |
メタデータ取得 |
cargo doc |
ドキュメント生成 |
cargo fetch |
依存クレート取得 |
cargo search |
クレート検索 |
cargo install |
実行可能パッケージ導入 |
cargo uninstall |
導入済みパッケージ削除 |
cargo rustc |
rustcオプション付きビルド |
| コマンド | 用途 |
|---|---|
rustc --version |
バージョン確認 |
rustc -vV |
詳細情報 |
rustc --help |
ヘルプ |
rustc FILE.rs |
コンパイル |
rustc -o NAME FILE.rs |
出力名指定 |
rustc -O FILE.rs |
最適化 |
rustc -g FILE.rs |
デバッグ情報付加 |
rustc -C opt-level=3 FILE.rs |
最適化レベル指定 |
rustc -C target-cpu=native FILE.rs |
CPU固有の最適化 |
rustc --edition=2024 FILE.rs |
Edition指定 |
rustc --explain CODE |
エラー解説 |
rustc --emit=asm FILE.rs |
アセンブリ出力 |
rustc --emit=llvm-ir FILE.rs |
LLVM IR出力 |
rustc --emit=obj FILE.rs |
オブジェクトファイル出力 |
rustc --print target-list |
ターゲット一覧 |
rustc --print cfg |
cfg情報 |
rustc --crate-type=rlib FILE.rs |
Rustライブラリ生成 |
rustc --crate-type=cdylib FILE.rs |
動的ライブラリ生成 |
rustc -D warnings FILE.rs |
Warningをエラーとして扱う |
rustc -C help |
コード生成オプション一覧 |
| コマンド | 用途 |
|---|---|
rustup --version |
rustupバージョン |
rustup show |
環境情報 |
rustup show active-toolchain |
有効なツールチェーン |
rustup update |
ツールチェーン更新 |
rustup update stable |
Stable更新 |
rustup self update |
rustup自体の更新 |
rustup toolchain list |
ツールチェーン一覧 |
rustup toolchain install |
ツールチェーン導入 |
rustup toolchain uninstall |
ツールチェーン削除 |
rustup default stable |
デフォルト設定 |
rustup override set |
ディレクトリごとの設定 |
rustup override unset |
Override解除 |
rustup override list |
Override一覧 |
rustup component list |
コンポーネント一覧 |
rustup component add |
コンポーネント追加 |
rustup component remove |
コンポーネント削除 |
rustup target list |
ターゲット一覧 |
rustup target add |
ターゲット追加 |
rustup target remove |
ターゲット削除 |
cargo +nightly build |
Nightlyでビルド |