Cargo Dependency Version

Haixin Pang March 06, 2025 #RUST #FAQ

First

Check the version of the dependency you want to use. Get the repository URL of the dependency from crates.io and tag(or commit hash) of the version you want to use.

Second

Write the dependency in the Cargo.toml file as follows:

[patch.crates-io]
crate_name = { git = "url",tag = "version" }

Or

crate_name = { git = "url",rev = "commit" }

Third

Run the following command to update the dependency:

cargo update -p crate_name