I expected there to be something like: cargo install stopwatch
but could not find it in the docs.
Finding the package version and manually adding the package to .toml:
[dependencies]
stopwatch="0.0.6"
Does not feel automated enough. :)
I expected there to be something like: cargo install stopwatch
but could not find it in the docs.
Finding the package version and manually adding the package to .toml:
[dependencies]
stopwatch="0.0.6"
Does not feel automated enough. :)
No, there is no such thing built in to Cargo. There is only a cargo install
subcommand which installs the binaries of a crate system-wide.
New third-party Cargo subcommands can be created, and cargo edit, does what you want.
These cargo subcommands can then be installed by cargo install
, in a fun meta circle!
% cargo install cargo-edit
# Now `cargo add` is available
% cargo add mycrate
As of Rust 1.62.0, you can use the following command to add dependencies, avoiding you to open the .toml file.
cargo add dependency@version
More info here: https://doc.rust-lang.org/nightly/cargo/commands/cargo-add.html