MCPcopy Index your code
hub / github.com/TimonPost/cargo-dependency-inheritor

github.com/TimonPost/cargo-dependency-inheritor @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
7 symbols 10 edges 1 files 0 documented · 0%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Cargo Workspace Dependency Inheritor

Utility that inherits dependencies from the main workspace if they occur n or more times in the workspace.

Workspace Inheritance was stabilized in version 1.64. See [workspace.package], [workspace.dependencies], and inheriting-a-dependency-from-a-workspace for more information.

How to Use

To inherit a dependency that occurs five or more times in the workspace, use the following command:

cargo install cargo-dependency-inheritor
cargo dependency-inheritor --workspace-path "path/to/workspace/Cargo.toml" -n 5

This command edits your toml files, make sure to have a back up

Process

Dependencies can be inherited from a workspace by specifying the dependency in the workspace's [workspace.dependencies] table. After that, add it to the [dependencies] table with workspace = true. This crate automates the process.

  1. Read packages defined in [workspace] section of the workspace-file.
  2. Note which dependencies occur n or more times.
  3. Update all dependencies that occurred n or more times:
  4. Turn dependency = "0.1.3" into inline tables.
  5. Add workspace = true key-value to the dependency inline table.
  6. Remove version from inline table if exists (this will be specified in the workspace file).
  7. Add [workspace.dependencies] table to root workspace file with all the dependencies that occurred n times and their version.

Result:

# in a project
[dependencies]
tokio = { workspace = true }

# in the workspace
[workspace.dependencies]
tokio = "1.0"

Core symbols most depended-on inside this repo

rewrite_dependency_table
called by 2
src/main.rs
to_toml
called by 2
src/main.rs
edit_workspace_dependency_table
called by 1
src/main.rs
main
called by 0
src/main.rs

Shape

Function 3
Class 2
Enum 1
Method 1

Languages

Rust100%

Modules by API surface

src/main.rs7 symbols

For agents

$ claude mcp add cargo-dependency-inheritor \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact