2024-05-25 17:46:51 +08:00
|
|
|
# Rust Study
|
|
|
|
## 自学 Rust 仓库
|
|
|
|
|
|
|
|
### 参考资料
|
|
|
|
- [Rust 语言中文社区](https://rustcc.cn/)
|
|
|
|
- [Rust 官方文档](https://doc.rust-lang.org/book/)
|
|
|
|
- [Rustlings](https://github.com/rust-lang/rustlings)
|
|
|
|
- [Rust by Example](https://doc.rust-lang.org/rust-by-example/)
|
|
|
|
- [Rust 程序设计语言](https://kaisery.github.io/trpl-zh-cn/)
|
|
|
|
|
|
|
|
|
2024-05-25 17:52:48 +08:00
|
|
|
## 子包
|
|
|
|
### 通用
|
|
|
|
#### 新建子包
|
2024-05-25 17:46:51 +08:00
|
|
|
例子:
|
|
|
|
```shell
|
|
|
|
cargo new 5.function --name function
|
|
|
|
```
|
2024-05-25 17:52:48 +08:00
|
|
|
#### 编译某个子包
|
2024-05-25 17:46:51 +08:00
|
|
|
```shell
|
|
|
|
cargo build --manifest-path 5.function/Cargo.toml
|
|
|
|
```
|
2024-05-25 17:52:48 +08:00
|
|
|
#### 运行某个子包
|
2024-05-25 17:46:51 +08:00
|
|
|
```shell
|
|
|
|
cargo run --manifest-path 5.function/Cargo.toml
|
|
|
|
```
|
|
|
|
|
2024-05-25 17:52:48 +08:00
|
|
|
### 基于 工作空间 workspace 管理子包
|
2024-05-25 17:46:51 +08:00
|
|
|
参考文档
|
|
|
|
- https://course.rs/cargo/reference/workspaces.html
|
|
|
|
|
|
|
|
#### 编译所有子包
|
|
|
|
```shell
|
|
|
|
cargo build --workspace
|
|
|
|
```
|
|
|
|
|
|
|
|
#### 编译工作空间下 某个子包
|
|
|
|
```shell
|
|
|
|
cargo build -p variables
|
|
|
|
```
|
|
|
|
|
|
|
|
#### 运行工作空间下 某个子包
|
|
|
|
```shell
|
|
|
|
cargo run -p function
|
|
|
|
```
|
|
|
|
|