Search code examples
rustrust-cargo

How to specify a commit in dependencies in Cargo.toml for optional features


There is a similar question here, but it doesn't cover the case of dependencies with features: How to specify a certain commit in dependencies in Cargo.toml?

I would like to test that a change in an upstream lib will work with my code before submitting the pull request, but I don't know how I can specify my github repo and the specific commit as the libs source and version.

I currently have this in my Cargo.toml:

karyon_net = "0.1.8"

[dependencies.karyon_jsonrpc]
version = "0.1.8"
features = ["tcp", "tls"]

And I want something like this with the ? replaced

karyon_net = { git = "https://github.com/PiRK/karyon.git", rev = "5923b2b47ff2699530f26cfeb5d45929a828eaa3" }

[dependencies.karyon_jsonrpc]
version = ?
features = ["tcp", "tls"]

I tried version = { git = "https://github.com/PiRK/karyon.git", rev = "5923b2b47ff2699530f26cfeb5d45929a828eaa3" } but it turns out version must be a semvver string.

I have been told there is a git = field, but I can't find any doc or example on how its syntax should work.


Solution

  • It seems like you have all the information you need as you specified karyon_net correctly. Perhaps you just don't fully understand TOML syntax?

    This is how it would look:

    [dependencies.karyon_jsonrpc]
    git = "https://github.com/PiRK/karyon.git"
    rev = "5923b2b47ff2699530f26cfeb5d45929a828eaa3"
    features = ["tcp", "tls"]
    

    Further reading: