Crate cargo_shear

Crate cargo_shear 

Source
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 files
  • package_analyzer - Analyzes packages to find issues
  • package_processor - Processes packages and detects unused dependencies
  • source_parser - Parses Rust source to extract data

§Usage

use cargo_shear::{CargoShear, CargoShearOptions};

let options = CargoShearOptions::new_for_test(
    std::path::PathBuf::from("."),
    false, // fix
);
let exit_code = CargoShear::new(std::io::stdout(), options).run();

Modules§

util

Structs§

CargoShear
The main struct that orchestrates the dependency analysis and removal process.
CargoShearOptions
Command-line options for cargo-shear.

Enums§

ColorMode
Color mode for output.
OutputFormat
Output format for cargo-shear.

Functions§

cargo_shear_options