书中给出一个种安装cargo-edit软件包。运行命令后,添加了好多东西:
liujianhuadeiMac:samp2_3 liujianhua$ cargo install cargo-edit
Updating crates.io index
Downloaded cargo-edit v0.12.2
Downloaded 1 crate (64.3 KB) in 9.51s
Installing cargo-edit v0.12.2
Updating crates.io index
Downloaded untrusted v0.9.0
Downloaded utf8parse v0.2.1
Downloaded anstyle-query v1.0.2
Downloaded atty v0.2.14
Downloaded colorchoice v1.0.0
Downloaded concolor-control v0.0.7
Downloaded concolor-query v0.0.4
Downloaded unicode-ident v1.0.12
Downloaded unicode-bidi v0.3.15
Downloaded cfg-if v1.0.0
Downloaded equivalent v1.0.1
Downloaded pathdiff v0.2.1
Downloaded url v2.5.0
Downloaded tinyvec_macros v0.1.1
Downloaded anstyle v1.0.6
Downloaded dunce v1.0.4
Downloaded form_urlencoded v1.2.1
Downloaded ureq v2.8.0
Downloaded serde_spanned v0.6.5
Downloaded unicode-normalization v0.1.23
Downloaded cargo-platform v0.1.8
Downloaded clap-cargo v0.12.0
Downloaded clap_lex v0.7.0
Downloaded itoa v1.0.11
Downloaded home v0.5.9
Downloaded winnow v0.5.40
Downloaded rustc-hash v1.1.0
Downloaded terminal_size v0.3.0
Downloaded toml_datetime v0.6.5
Downloaded socks v0.3.4
Downloaded vcpkg v0.2.15
Downloaded webpki-roots v0.25.4
Downloaded errno v0.3.8
Downloaded hex v0.4.3
Downloaded heck v0.5.0
Downloaded lazy_static v1.4.0
Downloaded percent-encoding v2.3.1
Downloaded strsim v0.11.1
Downloaded anstyle-parse v0.2.3
Downloaded autocfg v1.2.0
Downloaded fastrand v2.0.2
Downloaded env_proxy v0.4.1
Downloaded thiserror-impl v1.0.58
Downloaded smol_str v0.2.1
Downloaded security-framework-sys v2.10.0
Downloaded termcolor v1.4.1
Downloaded bitflags v1.3.2
Downloaded cargo_metadata v0.15.4
Downloaded thiserror v1.0.58
Downloaded byteorder v1.5.0
Downloaded either v1.10.0
Downloaded crossbeam-deque v0.8.5
Downloaded pkg-config v0.3.30
Downloaded anstream v0.6.13
Downloaded sct v0.7.1
Downloaded jobserver v0.1.28
Downloaded quote v1.0.36
Downloaded native-tls v0.2.11
Downloaded semver v1.0.22
Downloaded tempfile v3.10.1
Downloaded clap_derive v4.5.4
Downloaded camino v1.1.6
Downloaded core-foundation v0.9.4
Downloaded crates-index v0.19.13
Downloaded getrandom v0.2.14
Downloaded once_cell v1.19.0
Downloaded core-foundation-sys v0.8.6
Downloaded spin v0.9.8
Downloaded crossbeam-utils v0.8.19
Downloaded anyhow v1.0.82
Downloaded bitflags v2.5.0
Downloaded ryu v1.0.17
Downloaded log v0.4.21
Downloaded proc-macro2 v1.0.79
Downloaded tinyvec v1.6.0
Downloaded crossbeam-epoch v0.9.18
Downloaded subprocess v0.2.9
Downloaded indexmap v1.9.3
Downloaded toml v0.7.8
Downloaded serde_derive v1.0.197
Downloaded clap v4.5.4
Downloaded openssl-sys v0.9.102
Downloaded serde v1.0.197
Downloaded rayon-core v1.12.1
Downloaded security-framework v2.10.0
Downloaded cc v1.0.92
Downloaded indexmap v2.2.6
Downloaded base64 v0.21.7
Downloaded memchr v2.7.2
Downloaded toml_edit v0.19.15
Downloaded hashbrown v0.12.3
Downloaded hashbrown v0.14.3
Downloaded serde_json v1.0.115
Downloaded clap_builder v4.5.2
Downloaded aho-corasick v1.1.3
Downloaded rustls-webpki v0.101.7
Downloaded rayon v1.10.0
Downloaded git2 v0.17.2
Downloaded regex v1.10.4
Downloaded syn v2.0.58
Downloaded idna v0.5.0
Downloaded rustls v0.21.10
Downloaded regex-syntax v0.8.3
Downloaded rustix v0.38.32
warning: spurious network error (3 tries remaining): [92] Stream error in the HTTP/2 framing layer (HTTP/2 stream 137 was not closed cleanly: PROTOCOL_ERROR (err 1))
warning: spurious network error (3 tries remaining): [92] Stream error in the HTTP/2 framing layer (HTTP/2 stream 103 was not closed cleanly: PROTOCOL_ERROR (err 1))
Downloaded libssh2-sys v0.3.0
warning: spurious network error (3 tries remaining): [92] Stream error in the HTTP/2 framing layer (HTTP/2 stream 105 was not closed cleanly: PROTOCOL_ERROR (err 1))
warning: spurious network error (3 tries remaining): [92] Stream error in the HTTP/2 framing layer (HTTP/2 stream 141 was not closed cleanly: PROTOCOL_ERROR (err 1))
Downloaded regex-automata v0.4.6
Downloaded libc v0.2.153
Downloaded libgit2-sys v0.15.2+1.6.4
Downloaded libz-sys v1.1.16
Downloaded ring v0.17.8
Downloaded 110 crates (18.3 MB) in 8m 49s (largest was `ring` at 4.2 MB)
Compiling libc v0.2.153
Compiling proc-macro2 v1.0.79
Compiling unicode-ident v1.0.12
Compiling serde v1.0.197
Compiling pkg-config v0.3.30
Compiling jobserver v0.1.28
Compiling cc v1.0.92
Compiling quote v1.0.36
Compiling vcpkg v0.2.15
Compiling syn v2.0.58
Compiling tinyvec_macros v0.1.1
Compiling tinyvec v1.6.0
Compiling crossbeam-utils v0.8.19
Compiling unicode-normalization v0.1.23
Compiling percent-encoding v2.3.1
Compiling openssl-sys v0.9.102
Compiling libz-sys v1.1.16
Compiling ring v0.17.8
Compiling libssh2-sys v0.3.0
Compiling unicode-bidi v0.3.15
Compiling serde_derive v1.0.197
Compiling cfg-if v1.0.0
Compiling rustix v0.38.32
Compiling getrandom v0.2.14
Compiling idna v0.5.0
Compiling form_urlencoded v1.2.1
Compiling errno v0.3.8
Compiling log v0.4.21
Compiling serde_json v1.0.115
Compiling untrusted v0.9.0
Compiling utf8parse v0.2.1
Compiling spin v0.9.8
Compiling bitflags v2.5.0
Compiling anstyle-parse v0.2.3
Compiling crossbeam-epoch v0.9.18
Compiling url v2.5.0
Compiling libgit2-sys v0.15.2+1.6.4
Compiling itoa v1.0.11
Compiling hashbrown v0.14.3
Compiling colorchoice v1.0.0
Compiling anstyle-query v1.0.2
Compiling anstyle v1.0.6
Compiling ryu v1.0.17
Compiling semver v1.0.22
Compiling equivalent v1.0.1
Compiling rayon-core v1.12.1
Compiling memchr v2.7.2
Compiling indexmap v2.2.6
Compiling anstream v0.6.13
Compiling serde_spanned v0.6.5
Compiling toml_datetime v0.6.5
Compiling crossbeam-deque v0.8.5
Compiling terminal_size v0.3.0
Compiling camino v1.1.6
Compiling bitflags v1.3.2
Compiling autocfg v1.2.0
Compiling strsim v0.11.1
Compiling heck v0.5.0
Compiling clap_lex v0.7.0
Compiling thiserror v1.0.58
Compiling rustls v0.21.10
Compiling winnow v0.5.40
Compiling clap_builder v4.5.2
Compiling clap_derive v4.5.4
Compiling toml_edit v0.19.15
Compiling indexmap v1.9.3
Compiling aho-corasick v1.1.3
Compiling sct v0.7.1
Compiling rustls-webpki v0.101.7
Compiling thiserror-impl v1.0.58
Compiling anyhow v1.0.82
Compiling byteorder v1.5.0
Compiling either v1.10.0
Compiling regex-syntax v0.8.3
Compiling rayon v1.10.0
Compiling socks v0.3.4
Compiling regex-automata v0.4.6
Compiling toml v0.7.8
Compiling clap v4.5.4
Compiling hex v0.4.3
Compiling smol_str v0.2.1
Compiling cargo-platform v0.1.8
Compiling atty v0.2.14
Compiling rustc-hash v1.1.0
Compiling base64 v0.21.7
Compiling once_cell v1.19.0
Compiling hashbrown v0.12.3
Compiling webpki-roots v0.25.4
Compiling concolor-query v0.0.4
Compiling home v0.5.9
Compiling concolor-control v0.0.7
Compiling ureq v2.8.0
Compiling cargo_metadata v0.15.4
Compiling clap-cargo v0.12.0
Compiling regex v1.10.4
Compiling env_proxy v0.4.1
Compiling subprocess v0.2.9
Compiling pathdiff v0.2.1
Compiling dunce v1.0.4
Compiling termcolor v1.4.1
Compiling git2 v0.17.2
Compiling crates-index v0.19.13
Compiling cargo-edit v0.12.2
Finished release [optimized] target(s) in 11m 17s
Installing /Users/liujianhua/.cargo/bin/cargo-add
Installing /Users/liujianhua/.cargo/bin/cargo-rm
Installing /Users/liujianhua/.cargo/bin/cargo-set-version
Installing /Users/liujianhua/.cargo/bin/cargo-upgrade
Installed package `cargo-edit v0.12.2` (executables `cargo-add`, `cargo-rm`, `cargo-set-version`, `cargo-upgrade`)
这样就可以通过cargo add来向项目中简化添加依赖项,比如添加num,就执行cargo add num就行:
liujianhuadeiMac:samp2_3 liujianhua$ cargo add num
Updating crates.io index
Adding num v0.4.1 to dependencies.
Features:
+ std
- alloc
- libm
- num-bigint
- rand
- serde
Updating crates.io index
向项目中添加num::complex::Complex后,编译运行程序后如下:
这样以后,添加第三方依赖就简单多了。