Understanding overriding dependency in toml file

I was reading about overriding dependencies in Cargo and I found this from cargo book.

inorder to patch uuid crate I need to write something like this in my toml file

[patch.crates-io]
uuid = { path = "../path/to/uuid" }

Here I understand that patch might be a keyword which Cargo understands but I wanted to know what exactly crates-io mean here? what if i have a dependency not from crates.io and from github like this

[dependencies]
foo = { git = "http://github.com/foo-crate", branch = "trunk",}

How do i patch foo here?

crates-io is the name for the default registry. you can read the patch section in the cargo book. to quote:

Each key after [patch] is a URL of the source that is being patched, or the name of a registry.

to override an git dependency, you use the repository url, e.g.

[dependencies]
baz = { git = 'https://github.com/example/baz' }

[patch.'https://github.com/example/baz']
baz = { git = 'https://github.com/example/patched-baz.git', branch = 'my-branch' }
1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.