Rustのworkspaceの使い方
またまたRustについてです。 今回はworkspace機能についてよくわからなかったので勉強がてら書いていこうと思います。 Rustのワークスペースとは 大元であるCargoパッケージ内に複数パッケージがある場合に、相互にパッケージを扱うための機能です。 大きくなってきたプロジェクトで使用します。 Cargoのワークスペース - The Rust Programming Language 日本語版 公式のチュートリアルをなぞる形になりますが、やってみます。 まずはワークスペース機能のチュートリアルを行うCargoパッケージを作成します。 cargo new rust-workspace-playground 作成したパッケージに移動し、更にadderというパッケージを作成します。 cargo new adder この時点でcargo buildしても、adderの依存性をrust-workspace-playgroundには記述していないため、targetに出力されるのはrust-workspace-playgroundにあるhello worldプログラムのみです。 # cargo build実行後のtargetディレクトリの中身 target ├── CACHEDIR.TAG └── debug ├── build ├── deps │ ├── librust_workspace_playground-25fa51ac7f690b9a.rmeta │ ├── librust_workspace_playground-5cbc2718815bd853.rmeta │ ├── librust_workspace_playground-9f7880f2efd546b2.rmeta │ ├── rust_workspace_playground-01238b030f757f04 │ ├── rust_workspace_playground-01238b030f757f04.d │ ├── rust_workspace_playground-25fa51ac7f690b9a.d │ ├── rust_workspace_playground-5cbc2718815bd853.d │ └── rust_workspace_playground-9f7880f2efd546b2.d ├── examples ├── incremental │ ├── rust_workspace_playground-1xmwk187vqtbq │ ├── rust_workspace_playground-3oehp425tljca │ ├── rust_workspace_playground-3tb4u1zdv4nwu ├── rust-workspace-playground └── rust-workspace-playground.d ここで、rust-workspace-playgroundのCargo.tomlに以下のworkspaceセクションを追加します。 ...