Skip to content

Instantly share code, notes, and snippets.

@AstragoDE
Created April 8, 2023 14:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AstragoDE/e0be4ac4b1bf69957929ae5aa5e87c03 to your computer and use it in GitHub Desktop.
Save AstragoDE/e0be4ac4b1bf69957929ae5aa5e87c03 to your computer and use it in GitHub Desktop.
Commonly used Rust commands (by ChatGPT)

Cargo Commands

Command Description
cargo new Create a new Rust project
cargo build Build the Rust project
cargo run Build and run the Rust project
cargo test Run tests in the Rust project
cargo doc Generate documentation for the Rust project
cargo clean Clean the target directory of the Rust project
cargo update Update dependencies of the Rust project
cargo check Check the Rust project for errors without building
cargo publish Publish the Rust crate to crates.io
cargo install Install a Rust binary as a crate

Rustc Commands

Command Description
rustc Compile a Rust source file into an executable or library
rustc --version Show the version of the Rust compiler
rustc --help Show the help message for the Rust compiler
rustc <source_file.rs> Compile a specific Rust source file
rustc -O <source_file.rs> Compile a Rust source file with optimizations
rustc --crate-type Specify the type of output crate (e.g., bin, lib)
rustc --out-dir Specify the output directory for the compiled crate
rustc --emit Specify the type of output files (e.g., asm, ir, obj)

Rustup Commands

Command Description
rustup update Update the Rust toolchain
rustup show Show the currently installed Rust toolchain
rustup install Install a specific Rust toolchain
rustup uninstall Uninstall a Rust toolchain
rustup default Set the default Rust toolchain
rustup override Set the Rust toolchain for a specific directory
rustup target Add or remove Rust target platforms
rustup component Install or uninstall Rust components (e.g., rustfmt, clippy)
rustup self Update the Rustup toolchain installer
rustup doc Open the Rust documentation in a web browser
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment