Cargo
To build
sh
cargo buildTo run
sh
cargo runTo run an example
sh
cargo run --exmaple <name>To install new crates from crates.io
sh
cargo install <crate_name>This one is a nice crate.
This extends Cargo to allow you to add and remove dependencies by modifying your Cargo.toml
sh
cargo install cargo-editUsing cargo-edit crate
- Search
sh
cargo search <crate>- Add
sh
cargo add <crate>- Add with feature
sh
cargo add <crate> -F <feature>To format rust code in a specific style Add rustfmt.toml right next to Cargo.toml
Modify to have braces in next line
sh
brace_style = "AlwaysNextLine"
control_brace_style = "AlwaysNextLine"You need to set toolchain to nightly to work with this
sh
rustup override set nightlyRun this to format your code
sh
cargo fmtTo publish on crates.io
sh
cargo login
cargo publish --dry-run
cargo publish