Expand description
§cargo-shear
A tool for detecting and removing unused dependencies from Rust projects.
§Overview
cargo-shear analyzes your Rust codebase to identify dependencies that are declared
in Cargo.toml but never actually used in the code. It can automatically remove
these unused dependencies with the --fix flag.
§Architecture
The codebase is organized into several focused modules:
cargo_toml_editor- Handles modifications to Cargo.toml filespackage_analyzer- Analyzes packages to find issuespackage_processor- Processes packages and detects unused dependenciessource_parser- Parses Rust source to extract data
§Usage
use cargo_shear::{CargoShear, CargoShearOptions};
let options = CargoShearOptions::new(std::path::PathBuf::from("."));
let exit_code = CargoShear::new(std::io::stdout(), options).run();Modules§
Structs§
- Cargo
Shear - Top-level entry point: orchestrates
cargo metadata, runs each package through [PackageProcessor], optionally rewrites manifests, and renders the aggregated [ShearAnalysis] towriter. - Cargo
Shear Options - Command-line options for cargo-shear.
Enums§
- Color
Mode - Whether the terminal renderer should emit ANSI colors.
- Output
Format - Picks the renderer used for diagnostics on stdout.