|
|
@ -41,7 +41,7 @@ main.rs
|
|
|
|
#### 库 Package
|
|
|
|
#### 库 Package
|
|
|
|
再来创建一个库类型的 `package`:
|
|
|
|
再来创建一个库类型的 `package`:
|
|
|
|
```console
|
|
|
|
```console
|
|
|
|
$ cargo new my-test --lib
|
|
|
|
$ cargo new my-lib --lib
|
|
|
|
Created library `my-lib` package
|
|
|
|
Created library `my-lib` package
|
|
|
|
$ ls my-lib
|
|
|
|
$ ls my-lib
|
|
|
|
Cargo.toml
|
|
|
|
Cargo.toml
|
|
|
@ -50,7 +50,7 @@ $ ls my-lib/src
|
|
|
|
lib.rs
|
|
|
|
lib.rs
|
|
|
|
```
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
首先,如果你试图运行 `my-test`,会报错:
|
|
|
|
首先,如果你试图运行 `my-lib`,会报错:
|
|
|
|
```console
|
|
|
|
```console
|
|
|
|
$ cargo run
|
|
|
|
$ cargo run
|
|
|
|
error: a bin target must be available for `cargo run`
|
|
|
|
error: a bin target must be available for `cargo run`
|
|
|
|