Cargo
Cargo is the build system and package manager for Rust (there is no obvious equivalence for C or Go, as Go has its own built-in package management and there is no standard build system or package manager for C).
A new Cargo project can be created with: cargo new project_name. This will create a new directory in the current directory with the name project_name, containing:
.gitignore: Ignore files that should not be committed to version control, such as binaries (i.e./target). A new Git repository will be initialised, unless the project is within an existing repository. You can prevent this by adding--vcs noneto the arguments tocargo new.Cargo.toml: Build configuration and dependencies, in INI format.src/main.rs: Skeleton source file, containing the Hello World code.
Cargo assumes (requires?) that your source files (i.e. .rs) are in src and other files such as documentation are in the top level directory.
cargo build will build a binary with debugging information and no optimisation, which is what you want when developing. The binary will be placed in ./target/debug/ and will have the same name as the package. It will also create or update the Cargo.lock file, which you should never edit manually.
Although you can run the binaries using their relative file paths (e.g. ./target/debug/project_name), you can do this more easily with cargo run (this will also build the file if it does not exist or is out of date). This command is the same on all platforms supported by Rust, whereas the executable filename may differ.
cargo check will make sure the code can be compiled, but will not create an executable. This can be useful if you are still working on the code, but want to ensure that there are no compile-time errors. This is a useful command to run in Git hooks, where you don't want broken code to be checked into the repository but you don't need the executable. However, on small projects and fast machines, there may not be much time difference between cargo build and cargo check.
Crates
A crate is a collection of source files into a single project, using cargo new. Crates can be a binary (produce an executable file) or a library (used by other crates).
To use another crate in your project, edit Cargo.toml and add the crate name and version number under the dependencies section:
[dependencies] foo = "0.1.0"
Note that the crates namespace is flat rather than split by vendor, so crates have a single name like foo instead of bar/foo (PHP) or github.com/bar/foo (Go).
Publishing a crate via crates.io requires a GitHub account for authentication, although the crate code does not have to be hosted on GitHub.
Lock file
The Cargo.lock file contains the exact versions of crates, which may differ from those specified in Cargo.toml. For example, specifying version 0.1.0 of the foo crate may result in any version from 0.1.0 up to (but not including) 0.2.0. This is to ensure that everyone using the same codebase has the same versions of dependencies. cargo build will not update the versions of dependencies in the lock file, to do that you need to run cargo update, which will update to the latest version that still matches Cargo.toml. If you need a different version, such as 0.2.0 of foo, then you need to edit Cargo.toml first, then run cargo update.
Clippy
cargo clippy will apply linting rules to ensure that your code is idiomatic Rust. This goes beyond what cargo check does, although if you are using an IDE plugin it should format your code automatically, similar to how Go works with gofmt.