A crate is a Rust package containing an application or library. Cargo builds crates, resolves their dependencies, and can publish them to crates.io. Use a library crate when code needs to be consumed by another crate; keep dependencies declared in Cargo.toml. section 2.2 section 2.13
Declare a dependency
Add `rand = "0.8"` under `[dependencies]` in Cargo.toml, or run `cargo add rand`. Cargo interprets a bare version using a caret requirement, so choose version constraints deliberately. section 2.2
Choose crate boundaries for the job:
- For a larger project, split code into workspace members. Declare a local dependency with a path and list its directory under `[workspace] members`; membership alone does not declare the dependency. Members share a top-level Cargo.lock and target directory. section 2.10
- For integration tests, put tests under `tests/`. Cargo treats them as separate crates, so they can exercise exported interfaces but cannot call private functions; unit tests can cover those internals. section 7.1
- For an upstream fix, point a dependency at a local path or Git fork while pursuing an upstream change. Track upstream changes: a fork can become a lasting maintenance obligation. section 2.4
Before `cargo publish`, provide the required license and project details and ensure dependencies are available on crates.io. For private crates, private Git repositories and tags are recommended over the limited private-registry support described here. section 2.5

